首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Javascript onmouseout睡眠?

Javascript onmouseout睡眠?
EN

Stack Overflow用户
提问于 2008-12-21 20:57:16
回答 2查看 890关注 0票数 0

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

谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2008-12-21 21:02:34

代码语言:javascript
运行
复制
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);
}
票数 3
EN

Stack Overflow用户

发布于 2008-12-21 21:03:00

代码语言:javascript
运行
复制
var doSomething = function () {
    //Some code will here after 3 seconds of mouseout
};

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

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/384939

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档