2011-01-28 55 views
0

我問過的關於如何自動進行jQuery Blinds slideshow移動一個問題,有人在此頁上回答(帶有12票):在哪裏放這段腳本,以便這個幻燈片可以自動移動?

Is there a way to make this slideshow move automatically?

好像代碼工作對於大多數人,但我可以不要讓它爲我工作。我使用了原始的演示文件,並將代碼放在jquery.blinds-0.9.js的最底部,在「})(jQuery)之後;」但幻燈片仍然不動。我究竟做錯了什麼?我檢查了課程名稱,他們是正確的。

這是腳本的該塊:

var SlideChanger = function(seconds_each) { 
    var index = -1; 
    // on the first cycle, index will be set to zero below 
    var maxindex = ($(".change_link").length) - 1; 
    // how many total slides are there (count the slide buttons) 
    var timer = function() { 
    // this is the function returned by SlideChanger 
    var logic = function() { 
    // this is an inner function which uses the 
    // enclosed values (index and maxindex) to cycle through the slides 
     if (index == maxindex) 
     index = 0; // reset to first slide 
     else 
     index++; // goto next slide, set index to zero on first cycle 
     $('.slideshow').blinds_change(index); // this is what changes the slide 
     setTimeout(logic, 1000 * seconds_each); 
     // schedule ourself to run in the future 
    } 
    logic(); // get the ball rolling 
    } 
    return timer; // give caller the function 
} 

SlideChanger(5)(); // get the function at five seconds per slide and run it 
+0

的只有看起來像麻煩的行是'$(。slideshow')。blinds_change(index)`檢查在控制檯中 – Raynos 2011-01-28 02:09:58

回答

0

嘗試包裹的最後一行SlideChanger(5)();document.ready,像這樣:

$(function(){SlideChanger(5)();})

否則$(".change_link").length將概率返回0