Source Code:
(back to article)
Submit
Result:
Report an issue
<div id="demo" class="sample">Hello, World!</div> <br /> <div>className property after change: <span id="span1"></span></div> <script> const demoElement = document.getElementById("demo"); const span1 = document.getElementById("span1"); // Changing the attribute demo.className = "changed"; span1.innerHTML = demo.className; </script>