Change CSS style color - Javascript CSS Style Property

Javascript examples for CSS Style Property:color

Description

Change CSS style color

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>getElementById example</title> 
      <script>
  function changeColor(newColor) {
    var elem = document.getElementById("para1");
    elem.style.color = newColor;
  }/*www.  jav  a2 s .c om*/
  
      </script> 
   </head> 
   <body> 
      <p id="para1">Some text here</p> 
      <button onclick="changeColor('blue');">blue</button> 
      <button onclick="changeColor('red');">red</button>  
   </body>
</html>

Related Tutorials