7
Situation:
- I have a menu, and I need that when an event occurs
hover
, he displays a series of information from the respective menu - When the mouse goes to another menu, the displayed information has to be hidden and show the information from the other menu.
Problem:
- When I move the mouse quickly on the menu links, sometimes it ends up bugging, displaying the contents of 2 menus or more (which did not give time to hide)
Here is the Jsfiddle
Below is the code I’m using:
HTML:
<ul class="megamenu">
<li>
<a href="#" data-id="sbc_1">Teste</a>
</li>
<li>
<a href="#" data-id="sbc_2">Teste2</a>
</li>
<li>
<a href="#" data-id="sbc_3">Teste3</a>
</li>
<li>
<a href="#" data-id="sbc_4">Teste4</a>
</li>
</ul>
JS:
$(function(){
var id;
$('.megamenu a').mouseenter(function()
{
id = '#megamenuContent #'+$(this).data("id");
$(id).fadeIn('slow');
})
.mouseleave(function()
{
$(id).hide();
});
});
I wonder if anyone has any suggestions or any solution to this problem, in a last case I will end up choosing to use the event click
, but the ideal for my case is to use the hover
.
Do not use mouseenter because your site will not look cool on a touchscreen.
– Please_Dont_Bully_Me_SO_Lords