Javascript examples for DOM HTML Element:Style
Get a specified element's style object
<!DOCTYPE html> <html> <body> <h1 id="myH1" style="color:red">My Header</h1> <button onclick="myFunction()">get the style property of the H1 element</button> <p id="demo"></p> <script> function myFunction() {// w w w . j av a2 s . co m var x = document.getElementById("myH1").style.color; document.getElementById("demo").innerHTML = x; } </script> </body> </html>