Javascript examples for CSS Style Property:backgroundImage
Get the background image of a specific <div> element:
<!DOCTYPE html> <html> <body> <h1>Hello World!</h1> <div id="myDiv" style="background-image:url('http://java2s.com/resources/a.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> <script> function myFunction() {/*from w w w. j a v a 2 s .c o m*/ console.log(document.getElementById("myDiv").style.backgroundImage); } </script> </body> </html>