在Javascript中,我希望我的onmouseout事件在生效前休眠/暂停/等待/(这里不确定正确的术语)三秒钟。这是如何实现的?
谢谢
发布于 2008-12-21 21:02:34
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);
}
发布于 2008-12-21 21:03:00
var doSomething = function () {
//Some code will here after 3 seconds of mouseout
};
anElement.onmouseout = function () {
setTimeout(doSomething, 3000);
};
上面的代码所做的是在onmouseout
被调用3秒后执行doSomething
函数
https://stackoverflow.com/questions/384939
复制相似问题