Image heightProperty

Image 对象参考手册Image Object

Definition and Usage

The height property sets or returns the value of the height attribute of an image.

The height attribute specifies the height of an image.

Syntax

imageObject.height=pixels


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the height property.


Examples

Examples

The following example sets the height and width of an image:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function changeSize(){
    document.getElementById("compman").height="250";
    document.getElementById("compman").width="300";
}
</script>
</head>
<body>

<img id="compman" src="compman.gif.html" width="107" height="98">
<br><br>
<input type="button" onclick="changeSize()" value="Change image size">

</body>
</html>

Try it Yourself »


Image 对象参考手册Image Object Other Extensions