Home  >  Article  >  Web Front-end  >  Solution to bubbling problem based on mouseout, mouseover and other similar events_javascript skills

Solution to bubbling problem based on mouseout, mouseover and other similar events_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:14:29995browse

I’ve been writing something recently, which is quite disturbing. A pop-up layer with other elements on top. The original intention is that when the mouse leaves the pop-up layer, some actions will be performed. However, in actual applications, when the mouse leaves the elements in the pop-up layer, it will also Activate these actions. I tried various browser methods to stop event bubbling, but none worked.

There are still many experts in our javaeye. I found the following code in a buddy’s blog:

Copy the code The code is as follows:

function isMouseLeaveOrEnter(e, handler) {
if (e.type != 'mouseout' && e.type != 'mouseover') return false;
var reltg = e .reledtarget? E.reledtarget: e.type == 'Mouseout'? E.Toelement: E.fromelement;
While (RELTG && RTG! = Handler)
Retg = de; Return ( reltg != handler);
}

This method is to determine whether the current element is the element that needs to execute the mouseout event, so that the above problems can be avoided.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn