Javascript DOM CSS Style background Property get

Introduction

Return the background property values of a document:

document.body.style.background;

View in separate window

<!DOCTYPE html>
<html>
<body style="background:#f3f3f3 url('background1.png') no-repeat right top;">

<h1>Hello World!</h1>

<button type="button" onclick="myFunction()">Get background values</button>

<p id="demo"></p>
<script>
function myFunction() {// w  w  w .j  av  a2s.c o  m
  document.getElementById("demo").innerHTML = document.body.style.background;
}
</script>

</body>
</html>



PreviousNext

Related