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") |
A Number, representing the height of the image, in pixels
The following code shows how to change the height of an image to 300px:
<!DOCTYPE html> <html> <body> <img id="myImg" src="http://java2s.com/resources/a.png" width="107" height="98"> <button onclick="myFunction()">Test</button> <script> function myFunction() {//from w ww . j a va 2s. c om document.getElementById("myImg").height = "300"; } </script> </body> </html>