Home >Web Front-end >JS Tutorial >Add implementation code for mouseenter and mouseleave events for non-IE browsers_javascript skills
First understand a few event object attributes
target refers to the event source object. Click on an element at the innermost level of the nested element, and that element is the target. IE6/7/8 corresponds to srcElement.
currentTarget refers to the element itself where the event handler is added. For example, in el.addEventListener, el is the currentTarget. IE6/7/8 does not have a corresponding attribute. You can use this in the handler instead, such as evt.currentTarget = this.
relativeTarget refers to event-related elements, generally used in mouseover and mouseout events. The corresponding ones in IE6/7/8 are fromElement and toElement.
mouseenter, mouseleave are still supported in IE9, see also Greg Reimer’s blog post Goodbye mouseover, hello mouseenter.
The difference between mouseenter and mouseover is that mouseenter will not trigger when moving inside the element. As follows