HTML DOM 中的Input Image Object用于表示 type=”image”的 HTML 元素。
此标记用于访问或创建元素。可以使用 getElementById() 方法访问此元素。
句法:
document.getElementById("MyImage");
返回值:返回 标签的属性, type=”image” 。
属性值:
Value | Description |
---|---|
alt | Set/return the value of the alt attribute of the input image. |
autofocus | Set/return if an input image automatically gets focus when the page loads. |
defaultValue | Set/return the default value of an input image. |
disabled | Set/return whether an input image is disabled, or not. |
form | Returns a reference of the form that contains the input image. |
formAction | Set/return the value of the formaction attribute of an input image. |
formEnctype | Set/return the value of the formenctype attribute of an input image. |
formMethod | Set/return the value of the formmethod attribute of an input image. |
formNoValidate | Set/return if the form-data is validated or not when submitted. |
formTarget | Set/return the value of formtarget attribute of an input image. |
height | Set/return the value of height attribute of input image. |
name | Set/return the value of name attribute of input image. |
src | Set/return the value of src attribute of input image. |
type | Return the type of form element of input element. |
value | Set/return the value of value attribute of input image. |
width | Set/return the value of width attribute of input image. |
示例 1:访问输入元素并返回 ID、类型和宽度。
HTML DOM Input Image Object
GeeksForGeeks
DOM Input Image Object
输出
- 点击按钮前:
- 点击按钮后:
示例 2:访问输入元素并返回目标、alt 和高度。
HTML DOM Input Image Object
GeeksForGeeks
DOM Input Image Object
输出
- 点击按钮前:
- 点击按钮后:
示例 3:访问 Input 元素并返回 formTarget、formEnctype 和 formAction。
HTML DOM Input Image Object
GeeksForGeeks
DOM Input Image Object
输出
- 点击按钮前:
- 点击按钮后:
支持的浏览器:
- 谷歌浏览器
- 火狐浏览器
- 边缘
- 苹果浏览器
- 歌剧