We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

这篇翻译不完整。请帮忙从英语翻译这篇文章

一组单选按钮。在单选按钮组内一次只能选择一个单选按钮。radio 按钮可以指示单选按钮组或后代的子节点。 如果您想要一个边框或 caption ,请将Radiogroup放在一个 groupbox内。radiogroup 默认为垂直方向。

更多信息可以在 XUL 教程 中找到。

Attributes
disabled, focused, preference, tabindex, value
Properties
accessibleType, disabled, focusedItem, itemCount, selectedIndex, selectedItem, tabIndex, value
Methods
appendItem, checkAdjacentElement, getIndexOfItem, getItemAtIndex, insertItemAt, removeItemAt

范例

Image:XUL_ref_radios.png
<radiogroup>
  <radio id="orange" label="Red"/>
  <radio id="violet" label="Green" selected="true"/>
  <radio id="yellow" label="Blue"/>
</radiogroup>

Attributes

disabled
 
类型:boolean
表示元素是被禁用的。

如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。

然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false

示例:

Image:XUL_ref_attr_disabled.png
// Disabling an element
document.getElementById('buttonRemove').setAttribute("disabled", "true");

// Enabling back an element by removing the "disabled" attribute
document.getElementById('buttonRemove').removeAttribute("disabled");

Firefox 3.5 note

For keyset elements, support for this attribute was added in Firefox 3.5.

focused
Type: boolean
This attribute is true if the element is focused.
preference
Type: id
Connects the element to a corresponding preference. This attribute only has any effect when used inside a prefwindow. More information is available in the Preferences System article.
tabindex
Type:integer
当用户按下 "tab" 键时焦点移动到元素上的顺序。tabindex 数字越大,顺序越靠后。

value
Type: string
The string attribute allows you to associate a data value with an element. It is not used for any specific purpose, but you can access it with a script for your own use.

Properties

accessibleType
Type: integer
A value indicating the type of accessibility object for the element.

disabled
Type: boolean
Gets and sets the value of the disabled attribute.

focusedItem
Type: radio element
Holds the currently focused item in the radiogroup, which may or may not be the same as the selected item. You can change the focused item by setting this property.
itemCount
Type: integer
Read only property holding the number of child items.
selectedIndex
Type: integer
Returns the index of the currently selected item. You may select an item by assigning its index to this property. By assigning -1 to this property, all items will be deselected.

selectedItem
Type: element
Holds the currently selected item. If no item is currently selected, this value will be null. You can select an item by setting this value. A select event will be sent to the element when it is changed either via this property, the selectedIndex property, or changed by the user.

tabIndex
Type: integer
Gets and sets the value of the tabindex attribute.

value
Type: string
Gets and sets the value of the value attribute.

Methods

Inherited Methods
addEventListener(), appendChild(), blur, click, cloneNode(), compareDocumentPosition, dispatchEvent(), doCommand, focus, getAttribute(), getAttributeNode(), getAttributeNodeNS(), getAttributeNS(), getBoundingClientRect(), getClientRects(), getElementsByAttribute, getElementsByAttributeNS, getElementsByClassName(), getElementsByTagName(), getElementsByTagNameNS(), getFeature(), getUserData, hasAttribute(), hasAttributeNS(), hasAttributes(), hasChildNodes(), insertBefore(), isDefaultNamespace(), isEqualNode, isSameNode, isSupported(), lookupNamespaceURI, lookupPrefix, normalize(), querySelector(), querySelectorAll(), removeAttribute(), removeAttributeNode(), removeAttributeNS(), removeChild(), removeEventListener(), replaceChild(), setAttribute(), setAttributeNode(), setAttributeNodeNS(), setAttributeNS(), setUserData

appendItem( label, value )
Return type: element
Creates a new item and adds it to the end of the existing list of items. You may optionally set a value. The function returns the newly created element.
checkAdjacentElement( dir )
Return type: no return value
Deselects the currently selected radio button in the group and selects the one adjacent to it. If the argument <var>dir</var> is true, the next radio button is selected. If it is false, the previous radio button is selected.
getIndexOfItem( item )
Return type: integer
Returns the zero-based position of the specified item. Items are numbered starting at the first item displayed in the list.
getItemAtIndex( index )
Return type: element
Returns the element that is at the specified index.
insertItemAt( index, label, value )
Return type: element
This method creates a new item and inserts it at the specified position. You may optionally set a value. The new item element is returned.
removeItemAt( index )
Return type: element
Removes the child item in the element at the specified index. The method returns the removed item.

Interfaces
nsIAccessibleProvider, nsIDOMXULSelectControlElement

文档标签和贡献者

此页面的贡献者: xgqfrms-GitHub
最后编辑者: xgqfrms-GitHub,