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

Popular posts from this blog

mod rewrite - Using "?" when rewriting the URL -

.htaccess: Transfer name to index.php if not directory public -

Admob integration with pygame in android -