Javascript onmouseout 睡眠?

发布于 2024-07-09 22:19:58 字数 91 浏览 4 评论 0原文

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

谢谢

In Javascript, I want my onmouseout event to sleep/pause/wait/ (not sure of the proper terminology here) for three seconds before taking effect. How is that accomplished?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

_蜘蛛 2024-07-16 22:19:58
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);
}
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);
}
回梦 2024-07-16 22:19:58
var doSomething = function () {
    //Some code will here after 3 seconds of mouseout
};

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

上面代码的作用是在调用 onmouseout 3 秒后执行 doSomething 函数

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文