HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> .one{ color:green; font-size:20px; } </style> </head> <body> <p>Change my appearance</p> <p>Click on the button to set 'class' for the above paragraph.</p> <button onclick="myFunction()">Click Me</button> <script> var elem = document.getElementsByTagName("p")[0]; function myFunction(){ elem.setAttribute("class", "one") } </script> </body> </html>
OUTPUT
×

Save as Private