Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <head> <style> .mystyle { width: 300px; height: 50px; background-color: coral; color: white; margin-bottom: 10px; } .newClassName { width: 400px; height: 100px; background-color: lightblue; text-align: center; font-size: 25px; color: navy; margin-bottom: 10px; } </style> </head> <body> <p>Click the button to change the value of the class attribute of DIV to "newClassName".</p> <div id="myDIV" class="mystyle"> I am a DIV element </div> <button onclick="myFunction()">Try it</button> <script> function myFunction() { document.getElementById("myDIV").className = "newClassName"; } </script> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_element_classname3 by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:28:28 GMT --> </html>
Result:
Try it Yourself - © w3schools.com