code works in JSFiddle but not browser

后端 未结 2 438
清酒与你
清酒与你 2021-01-26 12:39

I\'m trying to move a fixed div containing an image of an airplane to the right and fade to 0 as the page is scrolled down from the top.

site: http://wp.ccrcc.org

2条回答
  •  感动是毒
    2021-01-26 13:16

    It looks like something is breaking $ by the time your code runs. You could work around that in the short term by using jQuery instead of $, like this:

      jQuery( document ).ready(function() {
        function flyOut() {
            var top = jQuery(document).scrollTop();
               if (top < 30) {
                     jQuery('#header-plane').animate({
                        'right': '0',
                        'opacity': 0
                     }, 'slow', function() {
                     });        
                  }
        }
    
        jQuery(window).scroll(function () {
          flyOut();
        });
     });
    

提交回复
热议问题