The code below shows an example of how to select sibling elements and parent elements in jQuery.
The Code
1 2 3 4 5 |
$(this).siblings().removeClass('current'); //removes class current from sibling elements $(this).parent().removeClass(); //removes class current from parent element (one level up) $(this).parents().removeClass(); //removes class current from all ancestor elements (parent, grandparent, and beyond) |