DOM Methods

DOMTokenList.supports()

Checks whether an attribute defines a token as supported, not whether it is present. Token lists without a defined supported vocabulary, such as classList, throw TypeError. Example result: true.

Formal Syntax & Structure

html syntaxhtml
list.supports(token)

Parameters & Attributes

NameTypeDescription
tokenstringNonempty token without ASCII whitespace.

Return Value

boolean

True for a supported token.

Working Example

Example Snippethtml
<p>  Result:  <output id="result"></output></p><script>  const result = document.getElementById("result");  (async () => {  const link = document.createElement("link"); result.textContent = link.relList.supports("stylesheet");  })().catch(error => { result.textContent = "Error: " + error.name; });</script>
HTML Reference