Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery select a div with a certain class, that doesn't have another class

<div class="fuu">   ... </div>  <div class="fuu no">   ... </div>  ... 

How can I select all fuu's besides the ones that have the .no class?

like image 866
Alex Avatar asked Apr 05 '11 03:04

Alex


People also ask

How do I select a specific class in jQuery?

In jQuery, the class and ID selectors are the same as in CSS. If you want to select elements with a certain class, use a dot ( . ) and the class name. If you want to select elements with a certain ID, use the hash symbol ( # ) and the ID name.

How do you select multiple elements with the same class?

Instead of using same id for multiple elements use the same class as the id of element is supposed to be unique. To select multiple elements with same class you can use attribute selector like $('[id=container]') but it is better to use class and keep the ids of elements unique.


1 Answers

Use :not() to exclude the other class:

$('.fuu:not(.no)') 
like image 197
BoltClock Avatar answered Sep 22 '22 08:09

BoltClock