停止函数,jQuery
我正在使用这个眨眼功能,
(function($)
{
$.fn.blink = function(options)
{
var defaults = { delay:500 };
var options = $.extend(defaults, options);
return this.each(function()
{
var obj = $(this);
setInterval(
function(){
if($(obj).css("visibility") == "visible") {
$(obj).css('visibility','hidden');
}
else{
$(obj).css('visibility','visible');
}
},
options.delay);
});
}
}(jQuery))
$("#bootUp p").blink({delay:300});
我希望它停止在 window.load 上,
我不确定到底该怎么做?任何帮助将不胜感激。谢谢!
I'm using this blink function
(function($)
{
$.fn.blink = function(options)
{
var defaults = { delay:500 };
var options = $.extend(defaults, options);
return this.each(function()
{
var obj = $(this);
setInterval(
function(){
if($(obj).css("visibility") == "visible") {
$(obj).css('visibility','hidden');
}
else{
$(obj).css('visibility','visible');
}
},
options.delay);
});
}
}(jQuery))
$("#bootUp p").blink({delay:300});
I'd like for it to stop on window.load
I'm not sure how to do it, exactly? Any help would be much appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
现场演示
您需要跟踪从 setInterval 返回的整数,然后清除Interval他们每个人。
Live Demo
You need to track the ints returned from setInterval and then clearInterval for each of them.
最正确的解决方案是存储
setInterval
返回的 id,然后使用clearInterval
清除它们。然而,更简单/脑残的方法就是:The most correct solution would be store the ids returned by
setInterval
, and then clear them all withclearInterval
. However, a more simple/braindead approach is just: