鼠标悬停在元素上时,使用什么事件代替onmouseout? [英] What event to use instead of onmouseout to run when mouse is not over the element?

查看:123
本文介绍了鼠标悬停在元素上时,使用什么事件代替onmouseout?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我没有悬停元素时运行脚本。这是某种以前在'onmouseover'事件中运行的其他东西的停用。
所以我使用onmouseout事件来运行这个脚本,但是,问题是如果我不悬停元素然后离开它,那么脚本就不会运行了。
如果将元素悬停得过快或窗口失去焦点,则会发生这种情况。
我该如何解决?

i want to run a script when i'm not hovering an element. It's some kind of deactivating something else that was run previously in 'onmouseover' event. So I'm using onmouseout event to run this script, however , the problem is that if i don't hover the element and then leave it , the script just don't run. this happens if e.g hover the element too fast or the window loses focus . How can i solve that?

编辑:让我以另一种方式说明这一点,我需要的是当鼠标未触及元素时要运行的事件。

let me illustrate this in another way , what i need is an event to be run when an element isn't touched by mouse.

推荐答案

你可以试试这个,

<div id="div1" onmouseover="fucntionIn()" onmouseout="functionOut()">"Special Area"</div>
<div id="div2" onmouseover="fucntionOut()">Other area</div>

逻辑是为页面其他区域的onmouseover事件写入停用代码。

the logic is to write deactivate code for onmouseover event of other area of the page.

这篇关于鼠标悬停在元素上时,使用什么事件代替onmouseout?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆