简体   繁体   English

当鼠标不在元素上方时,使用onmouseout运行吗?

[英]use onmouseout to run when mouse is not over the element?

I read this topic What event to use instead of onmouseout to run when mouse is not over the element? 我阅读了本主题,当鼠标不在元素上方时,要使用什么事件而不是onmouseout来运行?

The proposed method has not approached me . 所提出的方法尚未接近我。

How to determine that the cursor is moved to a other element? 如何确定光标已移动到另一个元素? I search alternative 我寻找替代品

Not sure what you are really looking for, but to check an event, that occures when entering / leaving an element you should use onmouseenter / leave -events 不确定您真正在寻找什么,但是要检查一个事件,该事件在输入/离开元素时发生,您应该使用onmouseenter / leave -events

As an alternative you could check something similiar by writing your own snippet, something like that: (just an example approach) 作为替代方案,您可以通过编写自己的代码片段来检查类似内容,例如:(仅是示例方法)

$(document).mousemove(function(evt){
// lets say you look for something like #header
   var myTarget = "header";
   var currentTarget = $(evt.target);
   if(myTarget != currentTarget.attr('id') ) {
    console.log('not on header')
   } else {
    console.log('on header')  
   }
})

edit Maybe you can give an example, so we could help more quick? 编辑也许您可以举个例子,这样我们可以更快地帮助您?

best 最好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 鼠标悬停在元素上时,使用什么事件代替onmouseout? - What event to use instead of onmouseout to run when mouse is not over the element? 将鼠标移到某些元素上时Onmouseout是否无法运行? - Onmouseout not to run when moving mouse over to certain elements? 当我在javascript中删除鼠标当前位于上方的元素时,会发生onMouseOut事件吗? - Does onMouseOut event occurs when I remove in javascript the element the mouse is currently over? 当鼠标移过按钮时,如何使用onmouseover和onmouseout来隐藏和取消隐藏按钮? - How to use onmouseover and onmouseout to hide and unhide a button when the mouse goes over it? 当鼠标移到与元素重叠的位置时,请勿触发onmouseout - Don't fire onmouseout when mouse moves to something overlaying the element javascript onmouseout也适用于鼠标悬停 - javascript onmouseout works also on mouse over 当我将光标移动到元素上而不离开元素时,将调用 onmouseout JavaScript 事件 - onmouseout JavaScript event being called when I move the cursor over an element without going out of the element 在元素上滚动时的动画鼠标效果 - Animated mouse effect when scrolling over element 鼠标悬停在内部元素上时丢失鼠标悬停 - Lost mouseover when mouse is over inner element 当元素消失时,onmouseout不会被触发 - onmouseout not fired when element goes away
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM