Javascript DOM CSS Style lineHeight Property get

Introduction

Return the line height of a <div> element:

alert(document.getElementById("myDiv").style.lineHeight);

View in separate window

<!DOCTYPE html>
<html>
<body>

<div id="myDiv" style="line-height:450%;">
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
</div>//from   w ww . ja v a 2  s  . c o m

<button type="button" onclick="myFunction()">Get line height</button>

<p id="demo"></p>

<script>
function myFunction() {
  document.getElementById("demo").innerHTML = document.getElementById("myDiv").style.lineHeight;
}
</script>

</body>
</html>



PreviousNext

Related