Remove multiple classes at once

不问归期 提交于 2019-12-02 12:59:13

removeClass accepts a space-delimited list of the class names to remove, so:

$("div.one, div.two, div.three").removeClass("one two three");

Assuming you're removing classes (like in your HTML) you can do the following

$('div').removeClass('one two three');

The documentation on removeClass states:

One or more space-separated classes to be removed from the class attribute of each matched element.

Try with .removeClass() like

$('div').removeClass('one two three');

see this LINK

Those aren't attributes, those are classes. Try:

$('div').removeClass('one two three');

Notice also that the function removeClass accepts one argument, not three. Just pass all of the intended class names into that one argument.

The attribute is the word "class" itself in this case.

use removeClass() to remove classes

Try

$('div').removeClass('one,two,three');

You are try to removing classes not attributtes:

Try with:

$('.someclass').removeClass('one two three');

Try this JQuery's removeClass method,

//Normal Practice
$("div.one, div.two, div.three").removeClass("one two three");

//Best Practice.
$('div').find('.one, .two, .three').removeClass('one two three');

For your reference have look into this JQuery removeClass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!