input type=radio -HTML元素

来源:百度文库 编辑:神马文学网 时间:2024/04/27 19:57:19
定义
创建单选钮控件。
Creates a radio button control.
注释
使用单选钮可以将用户可选择的范围限制到一组值中的一个。要实现这一功能,你必须为同一组的单选钮取相同的 name 值。
当用户提交表单时,只有选中的单选钮才会提交其 name / value 的对值,如果该单选钮有值的话。
要将一组单选钮中的一个设置为默认按钮,请将该单选钮的 checked 属性设置为 true。
只有当单选钮指定了 name 属性时,用户才能够选择该单选钮。要取消对某单选钮的选中,用户必须选择该单选钮组中的另外一个。
此元素在 Internet Explorer 3.0 及以上版本的 HTML 和脚本中可用。
此元素是一个内嵌元素。
此元素不需要关闭标签。
Use a radio button control to limit a user‘s selection to a single value within a set of values. To do this, you must link together each button in a set of radio buttons by assigning each button the same name.
When a user submits a form, a selected radio button only generates a name/value pair in the form data if the button has a value.
To select a radio button as the default button in a set, set the checked property of the button to true.
A user can select a radio button only if the button has a name. To clear a selected radio button, a user must select another button in the set.
The INPUT type=radio element is available in HTML and script as of Internet Explorer 3.0.
This element is an inline element.
This element does not require a closing tag.
示例代码
苹果
桔子
芒果

演示示例:使用单选钮,让用户在一组选项里只能选择一个
另见
input
相关教程和示例代码
HTML表单