2011-01-28 10 views
0

私は自動的にjQuery Blinds slideshow動きを作る方法で前に質問をし、誰かがこのページ(12票で1)に答えた:このスライドショーを自動的に動かすために、このスクリプトブロックをどこに置くのですか?

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

PROBます問題のように見える行は '$(。slideshow ')です。blinds_change(index)'コンソールで確認してください。 – Raynos

+1

idkですが、「12投票回答」を回答として受け入れる必要があります – JCOC611

答えて

0

はこのように、document.readyで最後の行SlideChanger(5)();をラップしてみてください。

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

そうでない場合$(".change_link").lengthがリターン0

関連する問題