Javascript DOM CSS Style Change

Description

Javascript DOM CSS Style Change

View in separate window


<!DOCTYPE html>

<html>
<head>
   <title>Programmatically Changings Styles</title>
   <script language="JavaScript">
      function ChangeStyles()//  w  w w.  j  av  a 2 s . c  om
      {
         // Modify the <p> tag style.
         var PTag = document.getElementById("MyPTag");
         PTag.style.fontFamily = "cursive";
         PTag.style.color = "blue";
         PTag.style.textAlign = "center";
         PTag.style.border = "medium double green";
      }
   </script>
</head>

<body>
   <h1>Programmatically Changings Styles</h1>
   <p id="MyPTag">Some Content</p>
   <input id="btnChange"
          type="button"
          value="Change the Styles"
          onclick="ChangeStyles()" />
</body>
</html>



PreviousNext

Related