HTML DOM Input Image 對象

Input Image 對象

Input Image 對象是 HTML5 中的新對象。

Input Image 對象表示 HTML <image> 元素。

訪問 Input Image 對象

您可以通過使用 getElementById() 來訪問 <image> 元素:

var x = document.getElementById("myImage");

提示:您也可以通過遍歷表單的 elements 集合 來訪問 Input Image 對象。

創建 Input Image 對象

您可以通過使用 document.createElement() 方法來創建 <image> 元素:

var x = document.createElement("INPUT");
x.setAttribute("type", "image");

Input Image 對象屬性

屬性 描述
autocomplete 設置或返回 email 字段的 autocomplete 屬性值。
alt 設置或返回 input image 的 alt 屬性值。
autofocus 設置或返回 input image 在頁面加載后是否應自動獲取焦點。
defaultValue 設置或返回 input image 的默認值。
disabled 設置或返回 input image 是否被禁用。
form 返回對包含 input image 的表單的引用。
formAction 設置或返回 input image 的 formaction 屬性值。
formEnctype 設置或返回 input image 的 formenctype 屬性值。
formMethod 設置或返回 input image 的 formmethod 屬性值。
formNoValidate 設置或返回在提交表單時是否應該驗證表單數據(form-data)。
formTarget 設置或返回 input image 的 formtarget 屬性值。
height 設置或返回 input image 的 height 屬性值。
name 設置或返回 input image 的 name 屬性值。
src 設置或返回 input image 的 src 屬性值。
type 返回 input image 字段的表單元素類型。
value 設置或返回 input image 的 value 屬性值。
width 設置或返回 input image 的 width 屬性值。

標準屬性和事件

Input Image 對象支持標準屬性事件

相關頁面

HTML 教程:HTML 表單

HTML 參考手冊:HTML <input> 標簽

HTML 參考手冊:HTML <input> type 屬性