JavaScript Reference/Javascript Properties/color
"color" Example
<html>
<body>
<script language="JavaScript">
function function1() {
document.getElementById("myFont").color = "green";
}
function function2() {
document.getElementById("myFont").color = "maroon";
}
</script>
<p>
<font face="Verdana" id="myFont">
<b>Sample text.</b>
</font>
</p>
<button onClick="function1();">Make Text Green</button>
<button onClick="function2();">Make Text Maroon</button>
</body>
</html>
"color" is applied to
+----------------+--------------------------------------------------------------+
| Applied_To |<basefont> <font> |
| |<hr> |
+----------------+--------------------------------------------------------------+
"color" Syntax and Note
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