Set line height from Javascript

Description

The following code shows how to set line height from Javascript.

Example


<html>
<head>
<script type="text/javascript">
  function bigger() {<!--  w  w  w  .j a va 2 s . c  o  m-->
    var div = document.getElementById("div1");
    div.style.lineHeight = "40px";
  }

  function smaller() {
    var div = document.getElementById("div1");
    div.style.lineHeight = "normal";
  }
</script>

</head>
<body>
  <a href="javascript:bigger();">bigger</a>
  <a href="javascript:smaller();">smaller</a>
  <div id="div1">
    <p>p1<br/>p1<br/>p1<br/>p1<br/></p>
    <p>p1<br/>p1<br/>p1<br/>p1<br/></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