DOM Methods

DOMTokenList.remove()

Removes specified tokens if present; unrelated tokens remain. Pass one or more separate token arguments. This is safer than rewriting className when other code manages other classes. Empty or ASCII-whitespace-containing arguments are invalid, even if the token is not currently present. Example result: card.

Formal Syntax & Structure

html syntaxhtml
list.remove(...tokens)

Parameters & Attributes

NameTypeDescription
...tokensstring[]Tokens to remove.

Return Value

undefined

Undefined; removes the specified tokens from the reflected set.

Working Example

Example Snippethtml
<p>  Result:  <output id="result"></output></p><script>  const result = document.getElementById("result");  (async () => {  const el = document.createElement("div"); el.className = "card active"; const list = el.classList;  list.remove("active"); result.textContent = el.className;  })().catch(error => { result.textContent = "Error: " + error.name; });</script>
HTML Reference