开发者

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

开发者 https://www.devze.com 2023-03-25 14:43 出处:网络
how would I use .removeClass to remove all matching classes instead of calling out each element individually?

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

So instead开发者_如何学JAVA of this:

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


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

or even

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

Hint: jQuery always works on all selected elements.


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


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");


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

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

精彩评论

暂无评论...
验证码 换一张
取 消