停止jQuery做它的事情? [英] Stopping jQuery from doing its thing?

查看:80
本文介绍了停止jQuery做它的事情?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

所以,当我向下滚动200px时,会出现div。当我向后滚动时,它会消失。这很好,直到我做了很多。



如果我像一个坚果一样向上和向下滚动,即使停止后div也会保持淡入淡出状态。这与这个实例无关,过去发生过很多事情,我一直想知道如何解决这个问题(通过尽快停止它,而不是每次我滚动上下滚动)。
$ b

这是可能的吗?

解决方案

.clearQueue比.stop()


工作得更好

I have this code.

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

So when I scroll down 200px it will make a div appear. When I scroll back up, it will disappear. This is fine, until I do it a lot.

If I scroll up and down like a nutter the div keeps fading in and out even after I stop. This isn't related to just this instance, it's happened a lot in the past and I've always wanted to know how to fix it (by making it stop as soon as I have, without doing it for everytime I scrolled up and down).

Is that possible?

解决方案

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

这篇关于停止jQuery做它的事情?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆