2016-09-20 4 views
0

私のワードプレスサイトでフェードイン効果をスクロールダウンして実装しようとしています。 私はこのチュートリアルに従いました:http://www.ordinarycoder.com/jquery-fade-content-scroll/ 問題は、私のページの本文にあるタグの間にJSコードを貼り付けると、動作しません(エラーコンソールは$が関数ではないということです)。何が間違っていますか? おかげで、

<script> 
$(function() { 
    $(window).scroll(function(){ 


     $('.fadeInBlock').each(function(i){ 

      var bottom_of_object = $(this).position().top + $(this).outerHeight(); 
      var bottom_of_window = $(window).scrollTop() + $(window).height(); 

      /* Adjust the "200" to either have a delay or that the content starts fading a bit before you reach it */ 
      bottom_of_window = bottom_of_window + 200; 

      if(bottom_of_window > bottom_of_object){ 

       $(this).animate({'opacity':'1'},500); 

      } 
     }); 

    }); 
}); 
</script> 
+0

2行目以降のコードはこの質問には該当しません。 –

答えて

0

これは、jQueryの機能では、あなたのページにjQueryライブラリが含まれていますか?

編集:あなたの例を見ると、$は何らかの理由でエイリアスとしてJQueryに割り当てられていません。スクリプトが修正する前にvar $ = jQueryを追加するか、$を変更して、完全名jQueryを参照するようにしてください。

関連する問題