HTML DOMTokenList remove()

❮ The DOMTokenList Object

Examples

Remove the "myStyle" class from an element:

const list = element.classList;
list.remove("myStyle");
Try it Yourself »

Add a "myStyle" class to an element:

const list = element.classList;
list.add("myStyle");
Try it Yourself »

Toggle "myStyle" on and off:

const list = element.classList;
list.toggle("myStyle");
Try it Yourself »

More examples below.


Description

The remove() method removes one (or more) tokens from a DOMTokenList.




Syntax

domtokenlist.remove(token, ...)

Parameters

Parameter Description
token Required.
The token(s) to remove from the list.

Return Value

NONE

More Examples

Remove multiple classes from an element:

element.classList.remove("myStyle", "anotherClass", "thirdClass");
Try it Yourself »

Get the number of class names for an element:

let numb = element.classList.length;
Try it Yourself »

Does an an element has a "myStyle" class?

let x = element.classList.contains("myStyle");
Try it Yourself »

Remove "anotherClass" if an element has a "myStyle" class.

if (element.classList.contains("mystyle")) {
  element.classList.remove("anotherClass");
}
Try it Yourself »

Browser Support

domtokenlist.remove() is a DOM Level 4 (2015) feature.

It is supported in all modern browsers:

Chrome Edge Firefox Safari Opera
Yes Yes Yes Yes Yes

domtokenlist.remove() is not supported in Internet Explorer 11 (or earlier).


❮ The DOMTokenList Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.