Source Code:
(back to article)
Submit
Result:
Report an issue
<style> .first-class { background-color: yellow; } .second-class { border: 2px dashed blue; } .third-class { display: none; } .fourth-class { font-size: 14px; } </style> <div id="myDiv">Multiple class handling</div> <script> document.getElementById("myDiv").classList.add("first-class", "second-class"); document.getElementById("myDiv").classList.remove("third-class", "fourth-class"); </script>