HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> .one{ color:red; } </style> </head> <body> <p>Click on the button to toggle the "one" class to this paragraph.</p> <button onclick="myFunction()">Toggle Button</button> <script> var elem = document.getElementsByTagName("p")[0]; function myFunction(){ elem.classList.toggle("one"); } </script> </body> </html>
OUTPUT
×

Save as Private