Skip to content

Instantly share code, notes, and snippets.

@benfoxall
Created June 13, 2011 13:35
Show Gist options
  • Save benfoxall/1022770 to your computer and use it in GitHub Desktop.
Save benfoxall/1022770 to your computer and use it in GitHub Desktop.
jQuery Expandable
li.closed ul{
display:none;
}
li a {
color:#ccc;
}
li.closed a{
color:#08f;
}
$.fn.expandable = function(){
return this.each(function(){
$('li > a:has(+ ul)', this).each(function(){
$(this).click(function(){
$(this).parent().toggleClass('closed');
}).click();
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment