I've been looking around for a couple of hours for a 3 level vertical accordion menu. Something like this: http://sandbox.scriptiny.com/javascript-accordion/index.html
Something really simple is enough, but i cant get anything to work with 3 levels. Can anyone provide me with a jquery snippet to get me started? I've tried using
$开发者_如何学运维('li').click(function(){
$(this).children('ul').children('li').toggle();
});
but it hides the submenu as well, not just the current childrens. Thanks
example from scratch:
<ul>
<li>
level 2
<ul>
<li>a</li>
<li>b</li>
</ul>
</li>
<li>
level 2
<ul>
<li>
level 3
<ul>
<li>c</li>
<li>d</li>
</ul>
</li>
<li>e</li>
<li>f</li>
</ul>
</li>
</ul>
$('li').click(function(ev) {
$(this).find('>ul').slideToggle();
ev.stopPropagation();
});
demo: http://jsfiddle.net/aCaEG/
check ui.accordion and see if helps you.
in my opinion, dont try to do something that already exist.
精彩评论