Edit This Code:
See Result »
<!DOCTYPE html> <html> <head> <style> .mystyle { width: 300px; height: 50px; text-align: center; background-color: coral; color: white; margin-bottom: 10px; } </style> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?73c27e26f610eb3c9f3feb0c75b03925"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </head> <body> <p>In this example, we first search for the element in the document with id="myDIV". Then, if this element has a class of "mystyle" - change its font size.</p> <div id="myDIV" class="mystyle"> I am a DIV element </div> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var x = document.getElementById("myDIV"); if (x.className === "mystyle") { x.style.fontSize = "30px"; } } </script> </body> </html>
Result: