'color' Example : Color « Style Layout « JavaScript DHTML






'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>

    
      
        
    
  








Related examples in the same category

1.Body text Color
2.Foreground Color Example
3.Change text color
4.Change element color
5.div.style.color="#fff";
6.Assign random color to