目录

HTML DOM input image 对象


输入图片对象

输入图片对象表示 type="image" 的 HTML <input> 元素。

访问输入图片对象

您可以使用 getElementById() 访问 type="image" 的 <input> 元素:

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

提示:您还可以通过搜索来访问 <input type="image">元素表格的集合。

创建输入图片对象

您可以使用 document.createElement() 方法创建 type="image" 的 <input> 元素:

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

输入图片对象属性

Property Description
alt Sets or returns the value of the alt attribute of an input image
autofocus Sets or returns whether an input image should automatically get focus when the page loads
defaultValue Sets or returns the default value of an input image
disabled Sets or returns whether an input image is disabled, or not
form Returns a reference to the form that contains the input image
formAction Sets or returns the value of the formaction attribute of an input image
formEnctype Sets or returns the value of the formenctype attribute of an input image
formMethod Sets or returns the value of the formmethod attribute of an input image
formNoValidate Sets or returns whether the form-data should be validated or not, on submission
formTarget Sets or returns the value of the formtarget attribute an input image
height Sets or returns the value of the height attribute of the input image
name Sets or returns the value of the name attribute of an input image
src Sets or returns the value of the src attribute of the input image
type Returns which type of form element the input image is
value Sets or returns the value of the value attribute of an input image
width Sets or returns the value of the width attribute of the input image

标准属性和事件

输入图片对象还支持标准特性事件


相关页面

HTML 教程:HTML 表单

HTML 参考:HTML <输入> 标签

HTML 参考:HTML <input> 类型属性