2013-03-07 59 views
5

我試圖設置幻燈片以使用數據屬性來設置每張幻燈片上的超時值。這適用於jQuery Cycle,但不適用於jQuery Cycle 2。我想我可能會使用錯誤的功能,但在Cycle 2文檔中找不到類似的內容?jQuery循環2中的變量滑動超時

HTML:

<div id="slides"> 
    <img src="img1.jpg" data-duration="1000" /> 
    <img src="img2.jpg" data-duration="2000" /> 
    <img src="img3.jpg" data-duration="3000" /> 
</div> 

JS:

$('#slides').cycle({ 
    fx: 'fadeout', 
    speed: 250, 
    timeoutFn: function(currElement, nextElement, opts, isForward) { 
     return parseInt($(currElement).attr('data-duration'), 10); 
    } 
}); 

回答

8

循環2支持直接。在幻燈片上使用data-cycle-timeout屬性而不是data-duration

+0

如果您以編程方式定義選項,這是如何工作的?感謝偉大的插件順便說一句,多年來爲我服務。 – 2014-03-19 03:38:38

+0

謝謝!已經嘗試過很多滑塊(Slick,Owl ..),但這是第一個有這個選項的人:) – numediaweb 2014-12-29 23:59:21