目录

HTML DOM button 对象


按钮对象

Button 对象代表一个 HTML <button> 元素。

访问按钮对象

您可以使用 getElementById() 访问 <button> 元素:

示例

var x = document.getElementById("myBtn");
亲自试一试 »

创建按钮对象

您可以使用 document.createElement() 方法创建 <button> 元素:

示例

var x = document.createElement("BUTTON");
亲自试一试 »

按钮对象属性

Property Description
autofocus Sets or returns whether a button should automatically get focus when the page loads, or not
disabled Sets or returns whether a button is disabled, or not
form Returns a reference to the form that contains a button
formAction Sets or returns the value of the formaction attribute of a button
formEnctype Sets or returns the value of the formenctype attribute of a button
formMethod Sets or returns the value of the formmethod attribute of a button
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 of a button
name Sets or returns the value of the name attribute of a button
type Sets or returns the type of a button
value Sets or returns the value of the value attribute of a button

标准属性和事件

Button 对象还支持标准特性事件


相关页面

HTML 参考:HTML <按钮> 标签