Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 17:14:29
Original
1023 people have browsed it

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.
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template