Table of contents
- 1. Examples
- 2. Attributes
- 3. Properties
- 4. Methods
- 5. Style classes
- 6. Related
A single choice in a menupopup
element. It acts much like a button
but it is rendered on a menu
.
More information is available in the XUL tutorial.
- Attributes
- acceltext , accesskey , allowevents , autocheck , checked , closemenu , command , crop , description , disabled , image , key , label , name , selected , tabindex , type , validate , value
- Properties
- accessibleType , accessKey , command , control , crop , disabled , image , label , labelElement , parentContainer , selected , tabIndex , value
- Style classes
- menuitem-iconic , menuitem-non-iconic
Examples

<menulist>
<menupopup>
<menuitem label="option 1" value="1"/>
<menuitem label="option 2" value="2"/>
<menuitem label="option 3" value="3"/>
<menuitem label="option 4" value="4"/>
</menupopup>
</menulist>
Attributes
Inherited from XUL element
align
, allowevents
, allownegativeassertions
, class
, coalesceduplicatearcs
, collapsed
, container
, containment
, context
,
, datasources
, dir
, empty
, equalsize
, flags
, flex
, height
,
, id
, insertafter
, insertbefore
, left
, maxheight
, maxwidth
,
, minheight
, minwidth
, mousethrough
, noinitialfocus
, observes
, ordinal
, orient
, pack
, persist
, popup
, position
, preference-editable
, querytype
, ref
, removeelement
, sortDirection
, sortResource
, sortResource2
, statustext
, style
, template
, tooltip
, tooltiptext
, top
, uri
, wait-cursor
, width
allowevents
autocheck
true or left out, the checked state of the button will be switched each time the button is pressed. If this attribute is false, the checked state must be adjusted manually. When autocheck is true, the button type should be "checkbox" or "radio". checked
hasAttribute() to determine whether this attribute is set instead of getAttribute().type attribute must be set to checkbox or radio for this attribute to have any effect.
checked
attribute is set to true, and you persist its value via the persist
attribute, Mozilla will fail to persist its value when the menuitem
is unchecked because of
bug 15232
. A workaround is to set the autocheck
attribute to false, then programmatically set the checked
attribute when the user selects the item, and set it to false instead of removing the attribute (i.e. do menuitem.setAttribute("checked", "false") instead of menuitem.removeAttribute("checked")) when the user unchecks the menuitem
, as a value of false will both correctly hide the checkmark and persist its hidden state.
crop
crop attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.startendleftrightcenternonenone and the displayed text is larger than this maximum width, you may be able to use the max-width CSS property (or the maxwidth attribute) to override this size. For example, for a menuitem in a menu you can add the following CSS rule when you want to use the value none:
menupopup > menuitem, menupopup > menu { max-width: none; }
description
disabled
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.
disabled
property which, except for menus and menuitems, is normally preferred to use of the attribute, as it may need to update additional state.
label
selected
selectedIndex
or selectedItem
property of the containing element. tabindex
tab" key. Elements with a higher tabindex are later in the tab sequence. validate
alwaysnever
value
Properties
Inherited PropertiesaccessibleType
labelElement
label
element label
element associated with the control. This is set when a label has a control
attribute pointing to this element. This property will be null when no label is associated with the control. parentContainer
New in Firefox 3
menu
element menu
element, or null if there isn't a containing menu. selected
true if this element is selected, or false if it is not. This property is read only. This property is available for menuitem and menuseparator elements in Firefox 3.
align
,
attributes, allowEvents
,
baseURI, boxObject
, builder
,
childElementCount,
childNodes,
children, className
,
clientHeight,
clientLeft,
clientTop,
clientWidth, collapsed
, contextMenu
, controllers
, database
, datasources
, dir
,
firstChild,
firstElementChild, flex
, height
, hidden
, id
,
lastChild,
lastElementChild, left
,
localName, maxHeight
, maxWidth
, menu
, minHeight
, minWidth
,
namespaceURI,
nextElementSibling,
nextSibling,
nodeName,
nodeType,
nodeValue, observes
, ordinal
, orient
,
ownerDocument, pack
,
parentNode, persist
,
prefix,
previousElementSibling,
previousSibling, ref
, resource
,
scrollHeight,
scrollLeft,
scrollTop,
scrollWidth, statusText
, style
,
tagName,
textContent, tooltip
, tooltipText
, top
, width
Methods
Style classes
-
menuitem-iconic - Use this class to have an image appear on the
menuitem. Specify the image using theimageattribute.
-
menuitem-non-iconic - Normally,
menuitems have a margin to the left for an image or checkmark. This class may be used to remove this margin so that the menuitem appears on the left edge of the menupopup.
Related
- Elements
menu,menubar,menulist,menupopup,menuseparator
Mozilla Developer Network