HTML - DOMTokenList entries() Method



HTML DOMTokenList entries() method returns an iterator which allows us to go through all the key/value pairs. The values are Arrays having [key, value] pair where each (key,value) pair represents a single token.

Syntax

domtokenlist.entries();

Parameter

This method does not accept any parameter.

Return Value

It returns an iterator.

Example of HTML DOMTokenList 'entries()' Method

Following example will illustrate the use of HTML DOMTokenList entries() method.

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOMTokenList entries() Method
    </title>
</head>
<body>
    <button onclick="fun()">Click me</button>
    <section id="iterator" class="itr itr2 itr3">HIIIIII</section>
    <p id="type"></p>
    <script>
        let result = document.getElementById("type");
        function fun() {
            let x = document.getElementById("iterator").classList.entries();
            for (let i of x) {
                result.innerHTML += i +"<br>";
            }
        }
    </script>
</body>
</html>

Supported Browsers

Method Chrome Edge Firefox Safari Opera
entries() Yes 1 Yes 12 Yes 1 Yes 1 Yes 12.1
html_dom.htm
Advertisements