0

Javascript では、onmouseout イベントが有効になる前に 3 秒間スリープ/一時停止/待機/ (ここでは適切な用語がわからない) する必要があります。それはどのように達成されますか?

ありがとう

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);
};

上記のコードが行うことは、呼び出されてdoSomethingから 3 秒後に関数を実行することです。onmouseout

于 2008-12-21T21:03:00.160 に答える