Get Style object - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Style

Introduction

The Style object represents an individual style statement.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
body {/*from   w  w  w. j  av  a 2 s  .c  o  m*/
    background-color: yellow;
    color: red;
}
</style>
</head>
<body>

<button onclick="myFunction()">display the style properties</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementsByTagName("STYLE")[0];
    document.getElementById("demo").innerHTML = x.innerHTML;
}
</script>

</body>
</html>

Related Tutorials