Javascript DOM CSS Style height Property get

Introduction

Return the height of an <img> element:

alert(document.getElementById("myImg").style.height);

View in separate window

<!DOCTYPE html>
<html>
<body>

<img id="myImg" src="image1.png" style="width:100px;height:132px;">
<br>

<button type="button" onclick="myFunction()">Return height of image</button>
<p id="demo"></p>
<script>
function myFunction() {/*www.ja v a 2 s .  c  om*/
   document.getElementById("demo").innerHTML = document.getElementById("myImg").style.height;
}
</script>

</body>
</html>



PreviousNext

Related