Stopping jQuery from doing its thing?

前端 未结 5 1741
渐次进展
渐次进展 2021-01-14 19:52

I have this code.

$(document).ready(function() {
$(\'#box\').hide();
$(window).bind(\'scroll\', function(){
    if($(this).scrollTop() > 200) {
        $(         


        
5条回答
  •  再見小時候
    2021-01-14 20:50

    Try using stop() before more animations are queued:

    $(document).ready(function() {
        $('#box').hide();
        $(window).bind('scroll', function(){
            if($(this).scrollTop() > 200) {
                $("#box").stop().fadeIn(300);
            }
            else {
                $("#box").stop().fadeOut(300);
            }
        });
    });
    

    See the documentation here: http://api.jquery.com/stop/

提交回复
热议问题