Monday, 26 August 2013

JQuery Remove all links inside a that have a particular class except for the one that's clicked

JQuery Remove all links inside a that have a particular class except for
the one that's clicked

In jQuery, how can I remove/disable or change the class of all links
inside a <div> that have a particular class except for the one that was
clicked? The clicked one's class needs to be changed.
<div class="test">
<div class="link" data-id="1">Link 1</div>
<div class="link" data-id="2">Link 2</div>
<div class="link" data-id="3">Link 3</div>
</div>
In this case, if I clicked Link 1, I'm trying to make Link 2 and Link 3
disappear or change their class, and change the class of Link 1 to noLink.
How can this be done. I'm familiar with add class, remove class, but I'm
stuck with getting all others to be removed or changed and change the
clicked one to another class.

No comments:

Post a Comment