ul, li {
list-style-type: none;
padding: 0; margin: 0;
}
JavaScript
//$('#menu').(function() {
// Find list items representing folders and
// style them accordingly. Also, turn them
// into links that can expand/collapse the
// tree leaf.
$('#menu').find('li > ul').each(function(i) {
// Find this list's parent list item.
var parent_li = $(this).parent('li');
// Style the list item as folder.
// Temporarily remove the list from the
// parent list item, wrap the remaining
// text in an anchor, then reattach it.
var sub_ul = $(this).remove();
parent_li.wrapInner('<a/>').find('a').click(function() {
// Make the anchor toggle the leaf display.
sub_ul.toggle('slide');
});
parent_li.append(sub_ul);
});
// Hide all lists except the outermost.
$('ul ul').hide();
//});
$(function(){
$('#menu-tree').find('span').click(function(e){
$(this).parent().children('ul').toggle('slide');
});
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.