Change font Weight to 900 in JavaScript

Description

The following code shows how to change font Weight to 900.

Example


<!--   w  ww . j av a 2 s.  c om-->
<html>
<head>
<script type="text/javascript">
function bigger() {
var div = document.getElementById("div1");
div.style.fontSize="larger";
div.style.letterSpacing="10px";
div.style.textAlign="justify";
div.style.textTransform="uppercase";
div.style.fontSize="xx-large";
div.style.fontWeight="900";
div.style.lineHeight="40px";
}

function smaller() {
var div = document.getElementById("div1");
div.style.fontSize="smaller";
div.style.letterSpacing="normal";
div.style.textAlign="left";
div.style.textTransform="none";
div.style.fontSize="medium";
div.style.fontWeight="normal";
div.style.lineHeight="normal";
}
</script>

</head>
<body>
<a href="javascript:bigger();">bigger</a>
<a href="javascript:smaller();">smaller</a>
<div id="div1">
<p>p1</p>
<p>p2</p>
</div>
</body>
</html>

Click to view the demo

The code above generates the following result.

Change font Weight to 900 in JavaScript
Home »
  Javascript Tutorial »
    Style »
      Font
Javascript Tutorial Font
Change font Size to larger in JavaScript
Change font Weight to 900 in JavaScript
Change font family in JavaScript
Change font size in JavaScript
Set font color with form control in JavaScr...
Set font size with form control in JavaScri...