Home > Web Front-end > JS Tutorial > Sharing the solution to the problem that the hover event in jQuery keeps flashing in IE

Sharing the solution to the problem that the hover event in jQuery keeps flashing in IE

黄舟
Release: 2017-06-26 11:21:34
Original
1443 people have browsed it

When using the hover event of jQuery, the menu often flashes because the mouse slides too fast. I believe many friends have encountered this. I have seen that the vertical drop-down menu I made keeps shrinking, which is very annoying. I also encountered this situation when I was designing a menu for a website today. As a result, I searched on Baidu for a long time and could not find a solution. Let’s complain here. Baidu is too bad, and the included content is of little value. Finally, I found a solution on Google. Now I will teach you how to solve the problem of jQuery hover causing non-stop flashing in IE.

$("#category ul").find("li").each( function() { 
$(this).mouseover( function() {
$(this).children("ul").show(); 
} ); 
$(this).mouseout( function() {
$(this).children("ul").hide();
 } ); 
} );
Copy after login

The menu will continue to flash when the mouse moves in the drop-down menu, indicating that the mouseover and mouseout events are continuously triggered.

In fact, the solution is very simple: change mouseover to mouseenter and mouseout to mouseleave. The mouseenter and mouseleave events are implemented in the jQuery library and are not native events of the browser. But the most important thing is to solve the problem of the menu constantly flashing!


$("#category ul").find("li").each( function() {
 $(this).mouseenter(function() { 
$(this).children("ul").show(); 
} );
 $(this).mouseleave(function() {
 $(this).children("ul").hide();
 } ); 
} );
Copy after login

The above is the detailed content of Sharing the solution to the problem that the hover event in jQuery keeps flashing in IE. For more information, please follow other related articles on the PHP Chinese website!

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