How to Add Style Using JavaScript

To add style using JavaScript, we make use of style property.  Example is given below.

<html>
<head>
<title>JavaScript Tutorial </title>
 
<script type="text/javascript">

 function ColorChange()
{
    document.getElementById("myDiv").style.color = "blue";
}

 </script>
</head>
<body>
 
<input type="button" value="Change Color" onclick="ColorChange()"/>
 <div id="myDiv"> Hello World! </div> 
 
</body>
</html>

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •