jQuery Failing to Target Children
-
05-02-2021 - |
Question
Any idea why this isn't working? The children of the unordered list are not sliding up like I expect..
Solution
here you go bro this looks like what you want:
OTHER TIPS
I was able to fix this by using mouseover
and mouseleave
with a selector on the children
like so:
$(document).ready (function(){
$('nav ul li').mouseover(function(){
$(this).children('ul').slideDown()
});
$('nav ul li').mouseleave(function(){
$(this).children('ul').slideUp();
});
});
There is some error in you code.
Check the fixed one.
$(document).ready (function(){
$('nav ul li').hover(function(){
$(this).children("ul").slideDown().
addClass('shown');
}, function(){
$('.shown').slideUp().removeClass(".shown");
});
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow