Stopping jQuery from doing its thing?

会有一股神秘感。 提交于 2019-12-01 09:19:26

jQuery has a stop() method - http://api.jquery.com/stop/

This article describes how to use it, seems to be exactly what you're looking for: http://www.learningjquery.com/2009/01/quick-tip-prevent-animation-queue-buildup

Use the stopdocs function

You simply need to call $('#box').stop(true,true).fadeIn(300); and $('#box').stop(true,true).fadeOut(300); respectively

You have to add stop function to your queue like this: $('#box').stop(true).fadeOut(300);

function stop() description: see here

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/

.clearQueue() worked much better than .stop()

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!