[英]What event to use instead of onmouseout to run when mouse is not over the element?
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.
这是某种以前在'onmouseover'事件中运行的其他东西的停用。 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.
所以我使用onmouseout事件来运行这个脚本,但问题是 ,如果我不悬停元素然后离开它,脚本就不会运行了。 this happens if eg hover the element too fast or the window loses focus .
如果例如将元素悬停得太快或窗口失去焦点,就会发生这种情况。 How can i solve that?
我怎么解决这个问题?
EDIT: let me illustrate this in another way , what i need is an event to be run when an element isn't touched by mouse.
编辑:让我以另一种方式说明这一点,我需要的是当鼠标未触及元素时要运行的事件。
you can try this, 你可以尝试这个,
<div id="div1" onmouseover="fucntionIn()" onmouseout="functionOut()">"Special Area"</div>
<div id="div2" onmouseover="fucntionOut()">Other area</div>
the logic is to write deactivate code for onmouseover event of other area of the page. 逻辑是为页面其他区域的onmouseover事件编写停用代码。
如果你在整个页面上检测到onmouseover
(通过事件冒泡),当它进入一个新元素时,如果你最后观察到的原始元素是当前目标元素的父元素,如果不是,那么你知道它退出了原始DOM节点,即使onmouseout
没有触发。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.