Javascript examples for CSS Style Property:background
Click button to change the background property of the DIV element.
<!DOCTYPE html> <html> <head> <style> #myDIV {//w w w . j av a 2s . co m width: 500px; height: 500px; background: coral url('http://java2s.com/resources/a.png') no-repeat fixed center; color: white } </style> </head> <body> <button onclick="myFunction()">Test</button> <div id="myDIV"> <p>My DIV element</p> </div> <script> function myFunction() { document.getElementById("myDIV").style.background = "url('http://java2s.com/resources/a.png') lightblue repeat-x center"; } </script> </body> </html>