Return the background image of a specific <div> element:
alert(document.getElementById("myDiv").style.backgroundImage);
<!DOCTYPE html> <html> <body> <h1>Hello World!</h1> <div id="myDiv" style="background-image:url('background1.png');border:1px solid black;height:400px;width:400px;">This is a div element.</div> <br> <button type="button" onclick="myFunction()">Get the background image of div</button> <p id="demo"></p> <script> function myFunction() {/*from w ww.j a va2s .c om*/ document.getElementById("demo").innerHTML = document.getElementById("myDiv").style.backgroundImage; } </script> </body> </html>