o12d10
o12d10

Reputation: 798

Keep old class and toggle new class

I am trying to create collapsible tree. I this my leaf nodes have class="member". The code highlights the path user is on in the tree. The problem is when i am using $(this).toggleClass("xyz"); it is removing my "member" class. I want to keep both class on leaf node

<li class="member xyz">Name</li>

jsfiddle code

using the member class I have css style that changes bullet images on my original code. so, i need to keep the member class.

Upvotes: 2

Views: 102

Answers (1)

Eric J.
Eric J.

Reputation: 150108

Examine this code:

$("li.clickedli").removeAttr("class");

This removes the entire class attribute, thus removing all classes. Just set/clear the specific classes you need/don't need.

Upvotes: 5

Related Questions