DOMTokenList 介面表示了一個以空格作為分隔的內容集,通常來自 Element.classList (en-US)HTMLLinkElement.relList (en-US)HTMLAnchorElement.relList (en-US)HTMLAreaElement.relList (en-US) 等屬性。本介面與 Array 同樣是由 0 開始索引,且 DOMTokenList 是區分大小寫的。


This interface doesn't inherit any property.

DOMTokenList.length (en-US) Read only

Is an integer representing the number of objects stored in the object.


This interface doesn't inherit any method.

DOMTokenList.item() (en-US)

Returns an item in the list by its index (or undefined if the number is greater than or equal to the length of the list, prior to Gecko 7.0 returned null)

DOMTokenList.contains() (en-US)

Returns true if the underlying string contains token, otherwise false

DOMTokenList.add() (en-US)

Adds token to the underlying string

DOMTokenList.remove() (en-US)

Removes token from the underlying string

DOMTokenList.replace() (en-US)

Replaces an existing token with a new token.

DOMTokenList.supports() (en-US)

Returns true if a given token is in the associated attribute's supported tokens.

DOMTokenList.toggle() (en-US)

Removes token from string and returns false. If token doesn't exist it's added and the function returns true


DOM Standard
# interface-domtokenlist


BCD tables only load in the browser