Given the following HTML:
<div id="table-filters"> <ul> <li class="active">blah</li> <li>blah</li> <li>blah</li> <li>blah</li> </ul> </div>
Using table-filters as the jQuery selector, how can I clear out the elements having CLASS=ACTIVE
, no matter which LI
it happens to be on?
thanks
The syntax for Removing CSS classes to an element:removeClass(class_name);
To remove all CSS classes of an element, we use removeClass() method. The removeClass() method is used to remove one or more class names from the selected element.
The removeClass() method removes one or more class names from the selected elements. Note: If no parameter is specified, this method will remove ALL class names from the selected elements.
This should work:
$("#table-filters>ul>li.active").removeClass("active"); //Find all `li`s with class `active`, children of `ul`s, children of `table-filters`
You can also do like this :
$("#table-filters li").parent().find('li').removeClass("active");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With