I want to call a class within jquery.
<nav class="small-nav">
<ul>
<li><a href="#">Home</a></li> </ul>
</nav> <!-- End of small-nav -->
<script>$('.handle').on('click', function()
{$('nav .small-nav ul').toggleClass('open');
});
</script>
However this doesn't work. I've tried replacing as
$('small-nav ul') or $('.small-nav ul') or $("nav '.small-nav' ul")
or $('nav.small-nav ul')
and it doesn't seem to work.
I know the code is fine because when I remove the class from the nav and when I call just the nav ul as shown below, it works.
<nav>
<li><a href="#">Home</a></li>
</nav>
<script>$('.handle').on('click', function()
{$('nav ul').toggleClass('open');
});
</script>
So can someone please tell me how I can call the specific class? Or is it not working because I am trying to call a class within another class (open) ? How do I fix it so that I can call that particular nav class and not all nav in my website.
Thanks for reading.
ulin your markup.. so use<nav class="small-nav"> <ul> <li><a href="#">Home</a></li> </ul> </nav>then$('nav.small-nav ul')document.ready