HTML - DOMTokenList value Property



HTML DOMTokenList value property returns DOMTokenList serialized as a string.

Syntax

domtokenlist.value;

Return value

It returns string value representing serialized list of class names or token each separated by space.

Example of HTML DOMTokenList 'value' Property

Following example will illustarte the use of HTML DOMTokenList 'value' property.

<!DOCTYPE html>
<html lang="en">
<head>
    <title>HTML DOMTokenList value Property</title>
    <style>
        .color {
            background-color: #04af2f;
            color: white;
        }
        .font {
            font-size: 40px;
        }
        .align {
            text-align: center;
        }
    </style>
</head>
<body>
    <p id="add" class="color font align">
        Welcome to Tutorials Point...
    </p>
    <button onclick="fun()">Click me</button>
    <p>
        Click to get the list of classes(tokens)
        in this document: 
    </p>
    <p id="value"></p>
    <script>
        function fun() {
            let x = document.getElementById("add").classList.value;
            document.getElementById("value").innerHTML = x;
        }
    </script>
</body>
</html>

Supported Browsers

Property Chrome Edge Firefox Safari Opera
value Yes 50 Yes 17 Yes 47 Yes 10 Yes 37
html_dom.htm
Advertisements