JavaScript Reference/Javascript Properties/background

Материал из Web эксперт
Перейти к: навигация, поиск

"background" Example

   <source lang="javascript">
   

<html> <head> <script>

   function function1() {
       document.all.myCell.background = "yourimage.gif"; 
   } 
   function function2() {
       document.all.myCell.background = "";
   } 

</script> </head> <body bgcolor="white" text="white">

Cell 1 content Cell 2 content Cell 3 content

<input type="button" name="button2" value="Add background image to Cell 1" onClick="function1();"> <input type="button" name="button3" value="Remove background image" onClick="function2();"> </body> </html>


     </source>
   
  


"background" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+

| Applied_To |<body> | | |
|

+----------------+--------------------------------------------------------------+

     </source>
   
  


"background" Syntax and Note

   <source lang="javascript">

Note: Read and write property. Sets the background image URL. The background image appears in front of any background color.

Syntax:

document.getElementById("elementID").background = value document.all.elementID.background = value // IE only


</source>