My goal is to display or hide the child class when the parent is hovered. I have multiple classes set up, similar to what is discussed in Jquery $(this) Child Selector.
Unfortunately, for some mysterious reason, it is not working.
This is what I currently have:
<div class="parentitem">
<div class="childitem">
</div>
</div>
In addition:
$("div.childitem").css({visibility: "hidden"});
$("div.parentitem").mouseenter(function(){
$("div.childitem").css({visibility: "visible"});
});
$("div.parentitem").mouseleave(function(){
$("div.childitem").css({visibility: "hidden"});
});
This setup works, but it affects all the children. What I really want is to target a specific div and its child only.
I have attempted several methods, like:
$(this).children("div.childitem").css({visibility: "visible"});
$(this).parent().children("div.childitem").css({visibility: "visible"});
$(this).next("div.childitem").css({visibility: "visible"});
Unfortunately, none of these approaches seem to be working for me.
If anyone can help me troubleshoot where I might have gone wrong, I would greatly appreciate it.
Thank you,
Deepak