JavaScript Reference/Javascript Properties/color

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

"color" Example

   <source lang="javascript">
   

<html> <body> <script language="JavaScript">

   function function1() {
       document.getElementById("myFont").color = "green";
   }
   function function2() {
       document.getElementById("myFont").color = "maroon";
   }

</script>

Sample text.

<button onClick="function1();">Make Text Green</button> <button onClick="function2();">Make Text Maroon</button> </body> </html>


     </source>
   
  


"color" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |<basefont> |

| |
|

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

     </source>
   
  


"color" Syntax and Note

   <source lang="javascript">

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

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

Syntax:

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


     </source>