HTML DOMTokenList item() Method
- baya forEach()
- baya keys()
- koma HTML DOMTokenList
Definition and Usage
The item() method returns the mark (token) at the specified index in the DOMTokenList.
There are two ways to access the mark at the specified index:
list.item(index)
or
list[index]
The simplest and most commonly used method is [index]。
Instance
Example 1
Get DOMTokenList from "demo":
let list = document.getElementById("demo").classList;
Example 2
Get the first item in the list:
let item = list.item(0);
Example 3
Result is the same:
let item = list[0];
Syntax
domtokenlist.item(index)or simply: domtokenlist[index]
Parameter
Parameter | Description |
---|---|
index |
Required. Index of the marked list. Tags are sorted in the order they appear in the document. Index starts from 0. |
Return Value
Type | Description |
---|---|
String | Mark at the specified index. |
null | If the index is out of range. |
Browser Support
All browsers support domtokenlist.item():
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | 10-11 | Support | Support | Support | Support |
Related Pages
- baya forEach()
- baya keys()
- koma HTML DOMTokenList