Button Object
按钮对象
The Button object represents a button in an HTML form. For each instance of an <input type="button"> tag in an HTML form, a Button object is created.
按钮对象可以代表在HTML表单中的按钮。每当HTML表单中有<input type="button">标签,一个按钮对象就建立起来了
You can access a Button object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().
你可以通过使用getElementById()或是表单元素数组的数字或是名称来访问按钮对象。
IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).
Button Object Properties
按钮对象属性
Property 属性 | Description 描述 | IE | F | O | W3C |
---|---|---|---|---|---|
accessKey | Sets or returns the keyboard key to access a button 设置或返回可访问按钮的键盘键 | 5 | 1 | 9 | Yes |
disabled | Sets or returns whether or not a button should be disabled 设置或返回按钮是否可用 | 5 | 1 | 9 | Yes |
form | Returns a reference to the form that contains the button 为包含按钮的表单返回一份参考 | 4 | 1 | 9 | Yes |
id | Sets or returns the id of a button 设置或返回按钮的id | 4 | 1 | 9 | Yes |
name | Sets or returns the name of a button 设置或返回按钮的name | 4 | 1 | 9 | Yes |
tabIndex | Sets or returns the tab order for a button 设置或返回按钮统计表 | 5 | 1 | 9 | Yes |
type | Returns the type of form element a button is 返回表单中按钮类型 | 4 | 1 | 9 | Yes |
value | Sets or returns the text that is displayed on the button 设置或返回按钮文字是否显示 | 4 | 1 | 9 | Yes |
Standard Properties
标准属性
Property 属性 | Description 描述 | IE | F | O | W3C |
---|---|---|---|---|---|
className | Sets or returns the class attribute of an element 设置或返回元素的class属性 | 5 | 1 | 9 | Yes |
dir | Sets or returns the direction of text 设置或返回文字方向 | 5 | 1 | 9 | Yes |
lang | Sets or returns the language code for an element 设置或返回元素的代码语言 | 5 | 1 | 9 | Yes |
title | Sets or returns an element's advisory title 设置或返回元素的咨询标题 | 5 | 1 | 9 | Yes |
Button Object Methods
按钮对象方法
Method 方法 | Description 描述 | IE | F | O | W3C |
---|---|---|---|---|---|
blur() | Removes focus from a button 删除对按钮的聚焦 | 4 | 1 | 9 | Yes |
click() | Simulates a mouse-click on a button 模仿鼠标点击 | 4 | 1 | 9 | Yes |
focus() | Gives focus to a button 聚焦到按钮上 | 4 | 1 | 9 | Yes |