html lists - Jquery: only show the UL with a child LI set to class = active -


i have kind of structure menu:

<ul id="accordion">  <li><a href="#">books</a>   <ul>     <li><a href="thrillers.html">thrillers</a></li>     <li><a href="scifi.html">sci-fi</a></li>     <li><a href="nf.html">non-fiction</a></li>   </ul>  </li>  <li><a href="#">games</a>   <ul>     <li><a href="rpg.html">rpg</a></li>     <li><a href="sim.html">simulations</a></li>     <li><a href="action.html">action</a></li>   </ul>  </li> </ul> 

(etc.)

now, people click on "rpg" want games submenu open on rpg-page. so, decided add class li selected:

... <ul>   <li class="active"><a href="rpg.html">rpg</a></li>   <li><a href="sim.html">simulations</a></li>   <li><a href="action.html">action</a></li> </ul> ... 

now, thing trying have jquery find ul class="active" , open ul.

i jquery:

<script>  $(document).ready(function () {      //hide submenu's onload     $('#accordion li').children('ul').slideup('fast');        $('#accordion a.item').click(function () {          /* first section */          //slideup or hide submenu         $('#accordion li').children('ul').slideup('fast');            //remove "over" class, arrow reset default         $('#accordion a.item').each(function () {             if ($(this).attr('rel')!='') {                 $(this).removeclass($(this).attr('rel') + 'over');               }         });          /* second section */                  //show selected submenu         $(this).siblings('ul').slidedown('fast');          //add "over" class, arrow pointing down         $(this).addclass($(this).attr('rel') + 'over');                   return false;      });  });  </script> 

what need after onload part have 1 want opened?

this may help:

$('#accordion > li > ul > li.active').parent().slidedown('fast'); 

Comments