admin管理员组文章数量:1317909
Can someone assist me on how I can delay this function?
$('#customer_quote').lightbox_me({
centered: true,
closeSelect: ".close",
onClose: function(){
$('div.error').remove()
}
})
});
I want this lightbox to open after 7 seconds.
Can someone assist me on how I can delay this function?
$('#customer_quote').lightbox_me({
centered: true,
closeSelect: ".close",
onClose: function(){
$('div.error').remove()
}
})
});
I want this lightbox to open after 7 seconds.
Share Improve this question asked Aug 10, 2012 at 15:26 breezybreezy 1,9181 gold badge18 silver badges35 bronze badges 2- use setTimeout() electrictoolbox./using-settimeout-javascript – Carlo Moretti Commented Aug 10, 2012 at 15:29
- 1 Additional Resource: developer.mozilla/en-US/docs/DOM/window.setTimeout – Nope Commented Aug 10, 2012 at 15:32
5 Answers
Reset to default 8Use setTimeout()
:
setTimeout(lightbox, 7000);
function lightbox() {
$('#customer_quote').lightbox_me({
centered: true,
closeSelect: ".close",
onClose: function(){
$('div.error').remove()
}
})
});
}
Give setTimeout
a shot:
setTimeout(function() {
$('#customer_quote').lightbox_me({
centered: true,
closeSelect: ".close",
onClose: function() {
$('div.error').remove()
}
});
}, 7000);
setTimeout(function(){
$('#customer_quote').lightbox_me({
centered: true,
closeSelect: ".close",
onClose: function(){
$('div.error').remove()
}
})
});
}, 7000);
Check this link out: To delay JavaScript function call using jQuery
Seems like you just use setTimeout with 7000
Use setTimeout
.
var delayedFunction = function() {
/* your code */
}
setTimeout(delayedFunction, 7000);
The second argument stands for the number of miliseconds.
Note also that this evokes an asynchronous event. The execution of your code will not stop at the line with setTimeout
for 7 seconds.
If you want to execute another code after this delay, you must do so in delayedFunction
, when the event fires.
本文标签: javascriptHow can i delay a functionStack Overflow
版权声明:本文标题:javascript - How can i delay a function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742029773a2416224.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论