0

在 Javascript 中,我希望我的 onmouseout 事件在生效前休眠/暂停/等待/(不确定此处的正确术语)三秒钟。这是如何实现的?

谢谢

4

2 回答 2

3
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-21T21:02:33.890 回答
1
var doSomething = function () {
    //Some code will here after 3 seconds of mouseout
};

anElement.onmouseout = function () {
   setTimeout(doSomething, 3000);
};

上面的代码所做的是在被调用doSomething3 秒后执行函数onmouseout

于 2008-12-21T21:03:00.160 回答