HTML DOMTokenList remove() Method
- Previous Page length
- Next Page replace()
- Go to the Previous Level HTML DOMTokenList
Definition and Usage
The remove() method removes one (or more) tokens from the DOMTokenList.
Instance
Example 1
Remove the "myStyle" class from the element:
const list = element.classList; list.remove("myStyle");
Example 2
Add the "myStyle" class to the element:
const list = element.classList; list.add("myStyle");
Example 3
Toggle the open/close of "myStyle":
const list = element.classList; list.toggle("myStyle");
Example 4
Remove multiple classes from the element:
element.classList.remove("myStyle", "anotherClass", "thirdClass");
Example 5
Get the number of classes of the element:
let numb = element.classList.length;
Example 6
Does the element have the "myStyle" class?
let x = element.classList.contains("myStyle");
Example 7
If the element has the "myStyle" class, delete "anotherClass".
if (element.classList.contains("mystyle")) { element.classList.remove("anotherClass"); }
Syntax
domtokenlist.remove(token, ...)
Parameters
Parameters | Description |
---|---|
token | Required. The token to be removed from the list. |
Return Value
None.
Browser Support
domtokenlist.remove() is a DOM Level 4 (2015) feature.
It is supported by all browsers:
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
Internet Explorer 11 (and earlier versions) does not support domtokenlist.remove().
Related Pages
- Previous Page length
- Next Page replace()
- Go to the Previous Level HTML DOMTokenList