javascript backgroundImage property
Translation results:
UK [ˈbækɡraund ˈimidʒ] US [ˈbækˌɡraʊnd ˈɪmɪdʒ]
Background image
javascript backgroundImage propertysyntax
Function:Set the background image of the element.
Syntax: Object.style.backgroundImage=url(URL)|none
Parameters: url(URL) Path to the image . none No background image.
Note: Please set an available background color, so that if the background image is not available, the page can also get good visual effects.
javascript backgroundImage propertyexample
<html> <head> <script type="text/javascript"> function changeStyle() { document.body.style.backgroundColor="#FFCC80"; document.body.style.backgroundImage="url(http://img.php.cn/upload/article/000/005/656/5af270fd37755429.jpg)"; } </script> </head> <body> <input type="button" onclick="changeStyle()" value="Set background image" /> </body> </html>
Run instance »
Click the "Run instance" button to view the online instance