.removeClass from all elements (versus a single defined element)
Asked Answered
O

4

8

how would I use .removeClass to remove all matching classes instead of calling out each element individually?

So instead of this:

$("input").removeClass("CO_form_alert");
$("select").removeClass("CO_form_alert");
Orthostichy answered 1/8, 2011 at 14:28 Comment(0)
G
24
$("input, select").removeClass("CO_form_alert");

or even

$(".CO_form_alert").removeClass("CO_form_alert");

Hint: jQuery always works on all selected elements.

Gurnard answered 1/8, 2011 at 14:30 Comment(0)
A
6
$(".CO_form_alert").removeClass("CO_form_alert");
Armadillo answered 1/8, 2011 at 14:30 Comment(0)
I
3

why couldn't you just use the following to do as you asked remove the class from all elements (versus a single defined element)

$(".CO_form_alert").removeClass("CO_form_alert");
Inhibit answered 29/8, 2015 at 0:48 Comment(0)
C
0

You can specify any number of selectors to perform the removeClass on:

$("select, input, banana").removeClass("CO_form_alert");
Carline answered 1/8, 2011 at 14:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.