Get the background image of a document via body.style property - Javascript CSS Style Property

Javascript examples for CSS Style Property:backgroundImage

Description

Get the background image of a document via body.style property

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body style="background:#f3f3f3 url('http://java2s.com/resources/a.png');">

<h1>Hello World!</h1>
<button type="button" onclick="myFunction()">Get background image</button>

<script>
function myFunction() {//from   w  w  w  . j  a  v  a 2  s .c  om
    console.log(document.body.style.backgroundImage);
}
</script>

</body>
</html>

Related Tutorials