当前位置: 首页 > 网络学院 > 客户端脚本教程 > HTML DOM > DOM Input Radio 对象
The Radio object represents a radio button in an HTML form. For each instance of an <input type="radio"> tag in an HTML form, a Radio object is created.
Radio对象代表了HTML表单中Radio按钮,每当HTML表单中出现<input type="radio">标签就意味着Radio被建立起来了
You can access a Radio object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().
你可以从表单元数组的数字或是名称来访问Radio对象,或是使用getELmentById()来访问它
IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).
Property 属性 | Description 描述 | IE | F | N | W3C |
---|---|---|---|---|---|
accept | Sets or returns a list of content types, which the server processing this form will handle correctly 设置或返回内容的类型,让服务器更准确的处理这个表单。 | - | Yes | ||
accesskey | Sets or returns the keyboard key to access the radio button 设置或返回能够访问这radio按钮的键盘按键。 | 4 | Yes | ||
align | Sets or returns the alignment of the radio button according to the surrounding text 设置或返回radio按钮相对周围文字的对齐方式 | - | Yes | ||
alt | Sets or returns an alternate text to display if the browser does not support radio buttons 设置或返回对于那些无法支持radio按钮浏览器的替换文字。 | - | Yes | ||
checked | Sets or returns the current state of the radio button (true if selected and false if not selected) 设置或返回radio按钮当前的状态(当被选中则为true,false则没有选中) | 3 | 1 | 2 | Yes |
defaultChecked | Sets or returns the default value of the checked attribute (true if checked by default and false if not) 设置或返回被选中属性的默认值(被默认的选中则为真,不然则为假) | 3 | 1 | 2 | Yes |
disabled | Sets or returns whether or not the radio button should be disabled 设置或返回radio按钮是否应该禁用。 | 5 | 1 | Yes | |
form | Returns a reference to the radio button's parent form 返回包含radio按钮表单的参考 | 3 | 1 | 2 | Yes |
id | Sets or returns the id of the radio button (In IE 4 this property is read-only) 设置或返回radio按钮的id(在IE4中这个属性只读) | 4 | 1 | No | |
name | Sets or returns the name of the radio button 设置或返回radio按钮的name | 3 | 1 | 2 | Yes |
size | Sets or returns the size of the radio button 设置或返回radio按钮的大小 | 3 | Yes | ||
tabIndex | Sets or returns the tab order for the radio button 设置或返回radio按钮由tab顺序所定义的索引 | 4 | Yes | ||
type | The type of the form element. For a radio object it will always be "radio" 返回表单元素类型,是radio按钮的话就会返回为"radio" | 3 | 1 | 3 | Yes |
value | Sets or returns the value of the value attribute of the radio button 设置或返回radio按钮属性的值 | 3 | 1 | 2 | Yes |
Method 方法 | Description 描述 | IE | F | N | W3C |
---|---|---|---|---|---|
blur() | Removes focus from the radio button 取消对radio按钮的聚焦 | 4 | 1 | 2 | Yes |
click() | Simulates a mouse-click on the radio button 模拟鼠标点击radio按钮 | 4 | 1 | Yes | |
focus() | Sets focus on the radio button radio按钮获得聚焦 | 3 | 1 | 2 | Yes |
select() | Selects the radio button 选中radio按钮 | 4 | 1 | 2 | No |
Syntax: object.event_name="someJavaScriptCode"
语法:对象.事件名称=“一些JS代码”
Event 事件 | Description 描述 | IE | F | N | W3C |
---|---|---|---|---|---|
onBlur | Executes some code when the radio button loses focus 当radio按钮失去聚焦的时候执行代码 | 4 | 1 | 2 | |
onClick | Executes some code when the user clicks on the radio button 当用户点击radio按钮的时候执行一些代码 | 4 | |||
onFocus | Executes some code when the radio button gets focus 当radio按钮得到聚焦的时候执行一些代码 | 3 | 1 | 2 | |
onSelectStart | Executes some code when the radio button is selected 当radio按钮被选中的时候执行一些代码 | 4 |