Interface DOMTokenList
length: number;
value: string;
"[iterator]"(): ArrayIterator<string>;
add(...tokens: string[]): void;
contains(token: string): boolean;
entries(): ArrayIterator<[number, string]>;
forEach(
callbackfn: (value: string, key: number, parent: DOMTokenList) => void,
thisArg?: any,
): void;
item(index: number): string | null;
keys(): ArrayIterator<number>;
remove(...tokens: string[]): void;
replace(token: string, newToken: string): boolean;
supports(token: string): boolean;
toggle(token: string, force?: boolean): boolean;
toString(): string;
values(): ArrayIterator<string>;
[index: number]: string;
}
Indexable
-
[index: number]: string
Properties
Readonlylength
The read-only length property of the DOMTokenList interface is an integer representing the number of objects stored in the object.
value
The value property of the DOMTokenList interface is a stringifier that returns the value of the list serialized as a string, or clears and sets the list to the given value.
Methods
[iterator]
-
Returns ArrayIterator<string>
add
-
The
add()method of the DOMTokenList interface adds the given tokens to the list, omitting any that are already present.Parameters
- ...tokens: string[]
Returns void
contains
-
The
contains()method of the DOMTokenList interface returns a boolean value — true if the underlying list contains the given token, otherwise false.Parameters
- token: string
Returns boolean
entries
-
Returns ArrayIterator<[number, string]>
forEach
-
forEach(
callbackfn: (value: string, key: number, parent: DOMTokenList) => void,
thisArg?: any,
): voidParameters
- callbackfn: (value: string, key: number, parent: DOMTokenList) => void
OptionalthisArg: any
Returns void
item
-
The
item()method of the DOMTokenList interface returns an item in the list, determined by its position in the list, its index.Parameters
- index: number
Returns string | null
keys
-
Returns ArrayIterator<number>
remove
-
The
remove()method of the DOMTokenList interface removes the specified tokens from the list.Parameters
- ...tokens: string[]
Returns void
replace
-
The
replace()method of the DOMTokenList interface replaces an existing token with a new token. If the first token doesn't exist, replace() returns false immediately, without adding the new token to the token list.Parameters
- token: string
- newToken: string
Returns boolean
supports
-
The
supports()method of the DOMTokenList interface returns true if a given token is in the associated attribute's supported tokens. This method is intended to support feature detection.Parameters
- token: string
Returns boolean
toggle
-
The
toggle()method of the DOMTokenList interface removes an existing token from the list and returns false. If the token doesn't exist it's added and the function returns true.Parameters
- token: string
Optionalforce: boolean
Returns boolean
toString
-
Returns string
values
-
Returns ArrayIterator<string>
The
DOMTokenListinterface represents a set of space-separated tokens. Such a set is returned by Element.classList or HTMLLinkElement.relList, and many others.MDN Reference