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

2 Answers

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`
1

You can also do like this :

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest