$(window).scroll() firing on page load

后端 未结 5 602
无人及你
无人及你 2020-12-20 16:01

Is there a way to prevent $(window).scroll() from firing on page load?

Testing the following code in Firefox 4, it fires even when I unplug the mouse.<

5条回答
  •  有刺的猬
    2020-12-20 16:26

    This was the solution I went for. Any improvements gratefully received.

       var scroll = 0;
        $(window).scroll(function(){
                        if (scroll>0){
                        console.log("Scroll Fired");
                        }
                        scroll++;
        });
    

提交回复
热议问题