[英]Javascript onmouseout Sleep?
In Javascript, I want my onmouseout event to sleep/pause/wait/ (not sure of the proper terminology here) for three seconds before taking effect. 在Javascript中,我希望我的onmouseout事件在生效之前先休眠/暂停/等待/(不确定此处的正确术语)三秒钟。 How is that accomplished?
如何完成的?
thanks 谢谢
function outfunction(event) {
var that = this; // to be able to use this later.
window.setTimeout(function() {
…
/* you can use 'that' here to refer to the element
event is also available in this scope */
}, 3000);
}
var doSomething = function () {
//Some code will here after 3 seconds of mouseout
};
anElement.onmouseout = function () {
setTimeout(doSomething, 3000);
};
What the above code does is execute the doSomething
function after 3 seconds of the onmouseout
being invoked 上面的代码所做的是在
onmouseout
调用3秒后执行doSomething
函数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.