Set font weight in Javascript

Description

The following code shows how to set font weight in Javascript.

Example


<html>
<head>
<script type="text/javascript">
  function bigger() {<!--from   w w  w. j  av a2  s . co  m-->
    var div = document.getElementById("div1");
    div.style.fontWeight = "900";
  }

  function smaller() {
    var div = document.getElementById("div1");
    div.style.fontWeight = "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





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window