Change element style color red - Javascript CSS Style Property

Javascript examples for CSS Style Property:color

Description

Change element style color red

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from   ww w. j a  va2  s .co m*/
document.getElementById('red').onclick = function(){
    this.style.color = "red";
}
    }

      </script> 
   </head> 
   <body> 
      <ul> 
         <li>
            <a id="red" href="#">List Item with Function</a>
         </li> 
         <li>
            <a href="#">List Item without Function</a>
         </li> 
      </ul>  
   </body>
</html>

Related Tutorials