Home >Web Front-end >JS Tutorial >Detailed explanation of the jQuery events mouseover and mouseout will also be triggered when the mouse passes over a child element

Detailed explanation of the jQuery events mouseover and mouseout will also be triggered when the mouse passes over a child element

黄舟
黄舟Original
2017-06-28 13:54:461668browse

javascript mouseover and mouseout events, when there are child elements inside the bound element,

passes through the bound element The mouseover and mouseout events will be triggered multiple times.

jquerySolution:

jquery’s mouseenter and mouseleave methods have fixed this problem and can be used directly to replace mouseover and mouseout

However, there is a small problem with mouseenter and mouseleave. When the mouse is directly entered from outside the document into the element bound to the event, mouseenter does not take effect

The temporary solution is to keep the element bound to the event away from the edge of the browser and try to leave at least 1px spacing.

In addition, jquery's hover() method is equivalent to using mouseenter and mouseleave. It can also solve the problems of mouseover and mouseout.

The above is the detailed content of Detailed explanation of the jQuery events mouseover and mouseout will also be triggered when the mouse passes over a child element. For more information, please follow other related articles on the PHP Chinese website!

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