Stopping jQuery from doing its thing?

前端 未结 5 1740
渐次进展
渐次进展 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:35

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

    0 讨论(0)
  • 2021-01-14 20:41

    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

    0 讨论(0)
  • 2021-01-14 20:41

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

    function stop() description: see here

    0 讨论(0)
  • 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/

    0 讨论(0)
  • 2021-01-14 20:58

    Use the stopdocs function

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

    0 讨论(0)
提交回复
热议问题