HTML DOM中的Input Image width屬性用于傳回的width屬性的值。
用法:
要傳回width屬性。imageObject.width
設定width屬性。imageObject.width = value;
屬性值:它包含一個數值,以像素為機關指定圖像的寬度。
傳回值:它傳回一個代表圖像寬度的數值。
範例1:本示例傳回輸入圖像寬度屬性。
/p>
HTML DOM Input Image width Property
GeeksforGeeks
DOM Input Image width Property
type="image" src=
"https://media.geeksforgeeks.org/wp-content/uploads/gfg-40.png"
alt="Submit"
formaction="#"
formtarget="#"
formenctype="text/plain"
width="48"
height="48">
function my_geek() {
// Return formTarget, formEnctype and formAction.
var txt = document.getElementById(
"myImage").width;
document.getElementById(
"Geek_h").innerHTML = txt;
}
輸出:
在單擊按鈕之前:

單擊按鈕後:
範例2:本示例設定“輸入圖像寬度”屬性。
HTML DOM Input Image width Property
GeeksforGeeks
DOM Input Image width Property
type="image" src=
"https://media.geeksforgeeks.org/wp-content/uploads/gfg-40.png"
alt="Submit"
formaction="#"
formtarget="#"
formenctype="text/plain"
width="48"
height="48">
function my_geek() {
// Return formTarget, formEnctype and formAction.
var txt = document.getElementById(
"myImage").width = "96";
document.getElementById(
"Geek_h").innerHTML = txt;
}
輸出:
在單擊按鈕之前:

單擊按鈕後:
支援的浏覽器:下面列出了HTML DOM輸入圖像寬度屬性支援的浏覽器:
谷歌浏覽器
IE浏覽器
Firefox
Opera
Safari