Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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");
like image 210
Jason Avatar asked Aug 01 '11 14:08

Jason


3 Answers

$("input, select").removeClass("CO_form_alert");

or even

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

Hint: jQuery always works on all selected elements.

like image 67
Tomalak Avatar answered Feb 24 '23 17:02

Tomalak


$(".CO_form_alert").removeClass("CO_form_alert");
like image 31
sjobe Avatar answered Feb 24 '23 18:02

sjobe


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");
like image 43
Joe Johnston Avatar answered Feb 24 '23 18:02

Joe Johnston