Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <head> <style> .democlass { color: red; } </style> </head> <body> <h1>Hello World</h1> <p>Click the button to add a class attribute with the value of "democlass" to the h1 element.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { document.getElementsByTagName("H1")[0].setAttribute("class", "democlass"); } </script> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_element_setattribute1 by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:29:01 GMT --> </html>
Result:
Try it Yourself - © w3schools.com