5
There are several Ivs with the class .categorias
and I need to display the element .nav-a
only in the div category that I have the mouse on top of it at the moment.
What is currently happening is that when I hover over any of the Divs .categorias
he displays the .nav-a
in all of them, and not only in .categorias
in question.
Follow the current code for reference.
$(document).ready(function(){
$('.nav-a').hide();
$('.categorias').mouseenter(function(){
$('.nav-a').fadeIn();
});
$('.categorias').mouseleave(function(){
$('.nav-a').fadeOut();
});
});
If . Nav-a is the child of . categories, do this $(this). find('.Nav-a'). fadein(); or $(this + '.Nav-a'). fadein() and tell me if it worked, it would be interesting to post your HTML
– Diego Vieira
Also post HTML, so we understand how your DOM is.
– Marcelo Aymone
@Diegovieira Regardless of HTML, your first suggestion seems correct. Post this as an answer!
– mgibsonbr
By the way, I’m assuming that the excitement of showing and hiding is important to you, right? Otherwise, a solution simply with CSS would suffice (and if the target are modern browsers, even the case of animation - using CSS3
transition
s)– mgibsonbr
Thank you, Diego Vieira’s solution solved my problem.
– Pablo Campina
Just a hint: if you will be using the same selector directly, and if the amount of items obtained will not change, transforms the
$(".nav-a")
in a variable. Typevar foo = $(".nav-a");
. This will make your life easier ;)– Oralista de Sistemas