jquery - show hide menu on click -
so have html:
<ul> <li><a>categ 1</a> <ul> <li><a>subcateg 1</a><li> <li><a>subcateg 1</a><li> </ul> <li><a>categ2</a> <ul> <li><a>subcateg 2</a><li> <li><a>subcateg 3</a> <ul> <li><a>sub sub categ 3</a><li> <li><a>sub sub categ 3</a><li> </ul> <li> </ul> </ul>
etc.
and js http://jsfiddle.net/fmm3a/ - click on red area(there needs image, test put red bg)
i open submenus don't close parent branch, when open other branch other ones close
thank you
the html list posted here full of errors (you not closing lists (''), have forgotten tags... well, after correcting them:
what this: http://jsfiddle.net/wpwmm/2/
here's code: http://jsfiddle.net/fmm3a/12/
$('li').click(function(e){ e.stoppropagation(); $(this).children('ul').slidetoggle(); $(this).closest('.parent').siblings().children('ul').slideup(); });
css:
ul{ display:none; } ul.visible{ display: block; }
in html need add class parent
main elements , class visible
main ul
. can see on fiddle.
Comments
Post a Comment