HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> .one{ color:red; } .two{ font-size:20px; } </style> </head> <body> <p class="two">Click on the button to check whether this paragraph contains "one" class.</p> <button onclick="myFunction()">Click Me</button> <p id="point"></p> <script> var x = document.getElementById("point"); var elem = document.getElementsByTagName("p")[0]; function myFunction(){ // try to replace "one" with "two" x.innerHTML = elem.classList.contains("one"); } </script> </body> </html>
OUTPUT
×

Save as Private