JavaScript Reference/Javascript Properties/bgColor

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

"bgColor" Example

   <source lang="javascript">
   

<html> <head> <script>

   function function1() {
       document.all.myCell.bgColor = "red";
   }
   function function2() {
       document.all.myCell.bgColor = "";
   }

</script> </head> <body bgcolor="#EEEEEE">

Cell 1 content Cell 2 content Cell 3 content Cell 4 content Cell 5 content Cell 6 content Cell 7 content

<input type="button" value="Add background color to Cell 1" onClick="function1();"> <input type="button" value="Remove background colors" onClick="function2();"> </body> </html>


     </source>
   
  


"bgColor" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |<body> document |

| |<marquee> | | |<tbody> | +----------------+--------------------------------------------------------------+ </source>

"bgColor" Syntax and Note

   <source lang="javascript">

Note: Read and write property. Sets the background color.

Value: Web color name or hexadecimal color value in #RRGGBB format.

Syntax:

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


</source>
| | |<tfoot> | | |<thead>