2016-05-24 1 views
0

私は、集中ロゴのホバー上に背景画像のサイクルを実行しようとしており、jQuery Cycle pluginを使用しています。jQueryサイクル・プラグイン[サイクル]終了中。セレクタによってゼロ要素が見つかりました

ただし、このエラーが発生します。[cycle] terminating;

page私は同じ問題を抱えていると思われますが、私が持っているエラーは解決していないようです。

何か助けていただければ幸いです。ありがとう。

HTML::

<div class="home" href="#"> 
    <a href="#about"> 
     <img id="logo" src="images/home/parableLogo.png"/> 
    </a> 

    <ul class="imgfill"> 
     <li><img src="images/home/1.jpg"></li> 
     <li><img src="images/home/2.jpg"></li> 
     <li><img src="images/home/3.jpg"></li> 
     <li><img src="images/home/4.jpg"></li> 
     <li><img src="images/home/5.jpg"></li> 
    </ul> 
</div> 

のjQuery:他のユーザーのソリューション次

$(document).ready(function(){ 
     // Cycle plugin 
     $('.imgfill').cycle({ 
      fx:  'none', 
      speed: 1, 
      timeout: 70 
     }).cycle("pause"); 

     // Pause & play on hover 
     $('#logo').hover(function(){ 
      $(this).find('.imgfill').addClass('active').cycle('resume'); 
     }, function(){ 
      $(this).find('.imgfill').removeClass('active').cycle('pause'); 
     }); 

    }); 

テストjQueryの:あなたは間違った選択を使用している

$(document).ready(function(){ 
     // Cycle plugin 
     $('.home').load('.imgfill', function(){ 
      $('.imgfill').cycle({ 
      fx:  'none', 
      speed: 1, 
      timeout: 70 
      }).cycle("pause"); 
     }); 


     // Pause & play on hover 
     $('#logo').hover(function(){ 
      $('.home').find('.imgfill').addClass('active').cycle('resume'); 
     }, function(){ 
      $('.home').find('.imgfill').removeClass('active').cycle('pause'); 
     }); 

    }); 
+0

のリンクしようとしたのですか? – Li357

+0

代わりに$(this)を$( '。home')に置き換えてください。この文脈では、$(this)は#logo要素です。 #logo内部に.imgfillセレクタ – AlmasK89

+0

@ AlmasK89こんにちは、ありがとう。エラーはなくなりましたが、サイクルは機能していません。 – user3453264

答えて

2

「$以下のコードを参照してください。 (this。).find( '。imgfill') "あなたは$( '。imgfill')を使用します。

ここ
$(document).ready(function(){ 
    // Cycle plugin 
    $('.imgfill').cycle({ 
     fx:  'none', 
     speed: 1, 
     timeout: 70 
    }).cycle("pause"); 

    // Pause & play on hover 
    $('#logo').hover(function(){ 
     $('.imgfill').addClass('active').cycle('resume'); 
    }, function(){ 
     $('.imgfill').removeClass('active').cycle('pause'); 
    }); 

}); 

あなたは他の質問に答えが提案どの実装作業バージョン http://codepen.io/mozzi/pen/eZqLxr

+1

ありがとうございます。また、私は隠されていたので、それは表示されていませんでした。 $( '。home')。find( '。imgfill')も同様に動作しますが、.findを使用するための追加手順です – user3453264

関連する問題