CKTIS / JavaScript
DOMTokenList.remove() — removing tokens
DOMTokenList.remove() removes specified tokens, such as element classes through classList. Learn how multiple arguments, missing tokens, and invalid values are handled.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
tokenList.remove(...tokens)DOMTokenList.remove() removes zero or more tokens. On element.classList, it updates the class attribute without removing the element. Missing tokens are ignored; the method returns undefined.
Pass separate arguments: element.classList.remove('selected', 'hidden'), not one space-containing string. An empty token throws a DOMException named SyntaxError; a token containing ASCII whitespace throws InvalidCharacterError.
All arguments are validated before removal. An invalid later argument therefore prevents earlier tokens from being removed. The example retains card after the error.
This is a WHATWG DOM API, not an ECMAScript-only feature. The example requires a browser document; a Node.js version alone does not establish API availability.
Examples
const element = document.createElement('div');
element.className = 'card selected hidden';
const result = element.classList.remove('selected', 'hidden', 'missing');
console.log(element.className);
console.log(result);
try {
element.classList.remove('card', 'bad token');
} catch (error) {
console.log(error.name);
}
console.log(element.className);Result
card undefined InvalidCharacterError card
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.