Javascript examples for CSS Style Property:backgroundImage
The backgroundImage property sets or gets the element background image.
Value | Description |
---|---|
url('value') | The image file URL location |
none | Default. No background image. |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | none |
Return Value: | A String, representing the background image |
CSS Version | CSS1 |
Get a background image for a document:
<!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() {// www . j a va2 s .c o m console.log(document.body.style.backgroundImage); } </script> </body> </html>