Hello. Code here: http://jsfiddle.net/4WQGY/

The meaning of the script is that if we have a nested ul, then we open it and return false. Otherwise, if nothing is nested, open the link.

Links work as it should. But I can not understand. If you click on "Kitchens" in the example and click, the next ul opens, and if you click on the link in it where there is no ul embedded, this ul will close. Why is that? How to fix? I already broke my head :)

  • Interest Ask! I will follow the answers ... I tried to add an onclick handler, but the effect remained the same - Vladyslav Matviienko

1 answer 1

$(function(){ $('.menu ul').hide(); $('.menu li.current').parent().show(); $('.menu li').has('ul').children('a').bind('click',function() { $(this).parent('li').children('ul').slideToggle(300); return false; }); }); 

http://jsfiddle.net/4WQGY/8/

  • Thank you very much) Works. But before the first part I could have guessed it myself) But still there is not enough knowledge - inferusvv
  • You can also $(this).next('ul').slideToggle(300); - mantigatos
  • Well it is clear. But not always with the next one - inferusvv