如何仅拦截顶级标记的mouseout事件 [英] How to intercept mouseout event for the top-level tag only

查看:68
本文介绍了如何仅拦截顶级标记的mouseout事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎附加到包含多个子元素的 div 标签的jQuery的 mouseout 回调将分别被调用用户将鼠标从任何这些子元素中拖出的时间。如果是这样,我怎么拦截顶级标记鼠标事件?

>解决方案

jQuery的 mouseout bubbles,这意味着你可以通过if语句来检查目标是否为父目录并将你的代码放在里面。



https://jsfiddle.net/ck0kbowt/ 例如:)

It seems that the mouseout callback from jQuery attached to the div tag containing several children elements will be called each time when user dragged a mouse away from any of these children elements. Am I right?

If so, how can I intercept the top-level tag mouse event only?

解决方案

jQuery's mouseout bubbles, which means you can put an if statement to check and see if the target is the parent and put your code inside that.

https://jsfiddle.net/ck0kbowt/ for example :)

这篇关于如何仅拦截顶级标记的mouseout事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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