Image height Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Image


The height property sets or gets the height attribute of an image.

Set the height property with the following Values

Value Description
pixels The height in pixels (e.g. height="100")

Return Value

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

The following code shows how to change the height of an image to 300px:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<img id="myImg" src="" width="107" height="98">

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

function myFunction() {//from   w ww .  j  a  va 2s. c  om
    document.getElementById("myImg").height = "300";


Related Tutorials