Image naturalHeight Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Image


The naturalHeight property returns the original height of an image.

This property is read-only.

Return Value

A Number, representing the original height of an image in pixels

The following code shows how to return the original height of an image:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<img id="myImg" src="" style="width:107px;height:500px;">

<button onclick="myFunction()">Test</button>

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

function myFunction() {/*www . ja  v a2 s  .  com*/
    var x = document.getElementById("myImg").naturalHeight;
    document.getElementById("demo").innerHTML = x;


Related Tutorials