Image width 屬性

定義和用法
width 屬性可設置或者返回圖片的width屬性的值。
width 屬性指定了圖片的寬度。
語法
imageObject.width=pixels
流覽器支持
所有主要流覽器都支持 width 屬性
實例
實例
改變圖片的高度與寬度:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.com)</title>
<script>
function changeSize(){
document.getElementById("compman").height="250";
document.getElementById("compman").width="300";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif" width="107" height="98">
<br><br>
<input type="button" onclick="changeSize()" value="修改圖像大小">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.com)</title>
<script>
function changeSize(){
document.getElementById("compman").height="250";
document.getElementById("compman").width="300";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif" width="107" height="98">
<br><br>
<input type="button" onclick="changeSize()" value="修改圖像大小">
</body>
</html>
