example.html
►
Run
Reset
<!doctype html> <html> <body> <h1>JavaScript HTMLElement.style Example</h1> <p class="message">This is a paragraph.</p> <p class="message">This is another paragraph.</p> <script> <!-- your JavaScript goes here --> var x = document.getElementsByClassName("message"); <!-- try changing the styles and run --> for (i = 0; i < x.length; i++) { x[i].style = "padding:20px;border:1px solid #bbb;"; } </script> </body> </html>