How to ignore multiple classes using the :not selector?

JqueryJquery Selectors

Jquery Problem Overview


I have this selector below where it ignores any li with the class show-all-boxes

$('.boxes li:not([class="show-all-boxes"]) input:checkbox')

What is the best way of adding multiple classes to be ignored by the selector? An example of this that I thought would work but it doesn't is:

$('.boxes li:not([class="show-all-boxes, show-all-circles, show-all-triangles"]) input:checkbox')

Jquery Solutions


Solution 1 - Jquery

The :not selector can take multiple CSS selectors as arguments ( http://api.jquery.com/not-selector ). E.g.

$('div:not(.a,.b)').empty()

http://jsfiddle.net/HFfcP/

Solution 2 - Jquery

try this :

$('.boxes li').not(".show-all-boxes, .show-all-circles, .show-all-triangles").find('input:checkbox')

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCecil TheodoreView Question on Stackoverflow
Solution 1 - JqueryThong KuahView Answer on Stackoverflow
Solution 2 - Jqueryredmoon7777View Answer on Stackoverflow