AnApprentice
AnApprentice

Reputation: 110960

Remove a CLASS for all child elements

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

Upvotes: 84

Views: 138441

Answers (3)

Marco Valeri
Marco Valeri

Reputation: 491

This should work:

$('#table-filters ul li .active').removeClass('active');

Upvotes: 1

insomiac
insomiac

Reputation: 5664

You can also do like this :

  $("#table-filters li").parent().find('li').removeClass("active");

Upvotes: 42

Joel
Joel

Reputation: 19358

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`

Upvotes: 147

Related Questions