MDN’s new design is in Beta! A sneak peek: https://blog.mozilla.org/opendesign/mdns-new-design-beta/

radiogroup

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

一组单选按钮。在单选按钮组内一次只能选择一个单选按钮。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
Type: boolean
Indicates whether the element is disabled or not. If this element is set to true the element is disabled. Disabled elements are usually drawn with grayed-out text. If the element is disabled, it does not respond to user actions, it cannot be focused, and the command event will not fire.

 

Image:XUL_ref_attr_disabled.png
<!-- Checkbox enables/disables the button -->
<checkbox label="Enable button" 
    onclick="document.getElementById('buttRemove').disabled = this.checked"/>
<button id="buttRemove" label="Remove All" disabled="true"/>

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
The tab order of the element. The tab order is the order in which the focus is moved when the user presses the "tab" key. Elements with a higher tabindex are later in the tab sequence.

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,