Return the height of an <img> element: - Javascript CSS Style Property

Javascript examples for CSS Style Property:height

Description

Return the height of an <img> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<img id="myImg" src="http://java2s.com/resources/c.png" style="width:100px;height:132px;">
<br>

<button type="button" onclick="myFunction()">Return height of image</button>

<script>
function myFunction() {// ww w  .  j  a v  a 2  s . com
    console.log(document.getElementById("myImg").style.height);
}
</script>

</body>
</html>

Related Tutorials