Skip to content

Instantly share code, notes, and snippets.

@oren
Created November 30, 2010 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oren/720918 to your computer and use it in GitHub Desktop.
Save oren/720918 to your computer and use it in GitHub Desktop.
how to remove a class from the kids?
$('.tree > ul > li').click(function(event){
$('.tree ul li').removeClass("selected");
$(this).addClass("selected");
$(this).find("ul > li").removeClass("selected");
});
<div class='tree'>
<ul>
<li class='list-with-no-kids'>company</li>
<li class='list-with-no-kids'>media</li>
<li class='list-with-no-kids'>blog</li>
<li class='list-with-kids'>creation
<ul class='hide'>
<li class='list-with-no-kids'>head</li>
<li class='list-with-no-kids'>foot</li>
</ul>
</li>
</ul>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment