jquery - Hiding and showing list under ul tags -
how use jquery hide/show (toggle) elements class secondlevel
upon clicking on toplevel link?
<ul> <li><a class="toplevel" href="#">hardware</a> <ul> <li><a class="secondlevel" href="#">bottling</a></li> <li><a class="secondlevel" href="#">brewing</a></li> <li><a class="secondlevel" href="#">cleaning</a></li> <li><a class="secondlevel" href="#">fermenting</a></li> <li><a class="secondlevel" href="#">kegging</a></li> <li><a class="secondlevel" href="#">measuring</a></li> <li><a class="secondlevel" href="#">testing</a></li> </ul> </li>
like this? jsfiddle
$('li ul').hide(); $('.toplevel').on('click', function() { $(this).siblings('ul').slidetoggle(); return false; });
Comments
Post a Comment