Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find all elements that DON'T have specific CSS class in jQuery?

I would like to get all form elements that don't have a specific CSS class. Example:

<form>
  <div>
    <input type="text" class="good"/>
    <input type="text" class="good"/>
    <input type="text" class="bad"/>
  </div>
</form>

What selector should I use to select all elements that don't have 'bad' css class?

Thank you.

like image 825
Valentin V Avatar asked Nov 28 '22 10:11

Valentin V


1 Answers

You can use the not() filter:

$("input").not(".bad")
like image 192
kgiannakakis Avatar answered Dec 09 '22 19:12

kgiannakakis