Skip to content

Instantly share code, notes, and snippets.

@paulmr
Created June 9, 2014 09:43
Show Gist options
  • Select an option

  • Save paulmr/586e136b17fa115be028 to your computer and use it in GitHub Desktop.

Select an option

Save paulmr/586e136b17fa115be028 to your computer and use it in GitHub Desktop.
.arenamenu {
margin: 0;
padding: 0;
}
.arenamenu-item.level0 {
/* display: inline; */
}
.arenamenu.active {
display: block;
}
.arenamenu.inactive {
display: none;
}
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<ul id="language-menu">
<li>Natural</li>
<li>Constructed
<ul>
<li>Esperanto</li>
<li>Volapük</li>
<li>Interlingua</li>
<li>Novial</li>
</ul></li>
</ul>
</body>
</html>
function menu(elm, level) {
if (typeof level != "number") level = 0;
elm.addClass("level" + level)
.addClass("arenamenu")
.addClass("inactive");
elm.children("li")
.addClass("arenamenu-item")
.addClass("level" + level)
.each(function(i, e) {
console.log(e);
e.children("ul").each(function(i, submenu) {
menu(submenu, level + 1);
});
});
}
menu($("#language-menu"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment