Listitem

A single row in a list box. The text of the listitem is specified either using listcell elements, or by placing a label attribute directly on the listitem element. You may also place other elements inside the listitem for more complex content.

More information about listitem

The listitem element implements the following interfaces:

nsIAccessibleProvider   nsIDOMXULSelectControlItemElement  

Attributes:

accesskey checked command crop current
disabled disabled image label preference
selected tabindex type value

Style Classes:

listitem-iconic

Properties and Methods:

accessKey accessible checked control crop
current disabled disabled image label
selected tabIndex value

Attributes:

Inherited from XUL Element:

align
allowevents
allownegativeassertions
class
coalesceduplicatearcs
collapsed
container
containment
context
contextmenu
datasources
dir
empty
equalsize
flags
flex
height
hidden
id
insertafter
insertbefore
left
maxheight
maxwidth
menu
minheight
minwidth
mousethrough
observes
ordinal
orient
pack
persist
popup
position
preference-editable
ref
removeelement
sortDirection
sortResource
sortResource2
statustext
style
template
tooltip
tooltiptext
top
uri
wait-cursor
width

accesskey

Type: character

This should be set to a letter that is used as a shortcut key. This letter should be one of the characters that appears in the label text for the listitem. This letter will typically be drawn underlined, although this behavior will be platform and theme specific. When the user presses ALT (or a similar key that varies on each platform) and the access key, the listitem will be activated from anywhere in the window. Although the value is case insensitive, a letter with the case matching the accesskey attribute will used if both cases exist in the label.

checked

Type: boolean

Indicates whether the listitem is checked or not.

command

Type: element id

Set to the id of a command element that is being observed by the element.

crop

Type: one of the values below

If the label of the listitem is too small to fit in its given space, the text will be cropped on the side specified by the crop attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.

current

Type: boolean

This attribute will be set to true if the listitem is the current item. This is typically used by a theme to customize the focus ring. To change the currently selected item in a listbox, use the listbox property selectedItem.

disabled

Type: boolean

Indicates whether the listitem is disabled or not. If this attribute is set to true, the listitem is disabled. This is usually drawn with the text in grey. If the listitem is disabled, it does not respond to user actions. The element cannot be focused and the command event will not fire. The element will still respond to mouse events. To enable the listitem, leave the attribute out entirely as opposed to setting the value to false.

disabled

Type: boolean

Indicates whether the listitem is disabled or not. If this attribute is set to true, the listitem is disabled. This is usually drawn with the text in grey. If the listitem is disabled, it does not respond to user actions. The element cannot be focused and the command event will not fire. The element will still respond to mouse events. To enable the listitem, leave the attribute out entirely as opposed to setting the value to false.

image

Type: image URL

The URL of the image to appear on the listitem. If this is attribute is left out, no image appears. The position of the image is determined by the dir and orient attributes. You must use the class 'listitem-iconic' to have an image appear.

label

Type: string

The label that will appear on the listitem. If this is left out, no text appears.

preference    Mozilla 1.8

Type: element id

Connects the listitem to a corresponding preference. This attribute only has any effect when used inside a prefwindow. The value of the preference will be updated to match the value property of the listitem.

selected

Type: boolean

Indicates whether the listitem is selected or not. This property is read only. To change the selection, set either the selectedIndex or selectedItem property of the containing listbox.

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 order sequence.

type

Type: string

You can make an item in a listbox a checkbox by setting this attribute to the value 'checkbox'.

value

Type: string

A value associated with the listitem. You may use it in a script for your own purposes.


Style Classes:

The following classes may be used to style the element. These classes should be used instead of changing the style of the element directly since they will fit more naturally with the user's selected theme.

listitem-iconic

Use this class to have an image appear on the listitem. Specify the image using the image attribute.


Properties and Methods:

Inherited from XUL Element:

align
allowEvents
blur
boxObject
boxObject.element
boxObject.getLookAndFeelMetric
boxObject.height
boxObject.screenX
boxObject.screenY
boxObject.width
boxObject.x
boxObject.y
builder
className
click
collapsed
contextMenu
controllers
database
datasources
dir
doCommand
flex
focus
getElementsByAttribute
height
hidden
id
left
maxHeight
maxWidth
menu
minHeight
minWidth
observes
ordinal
orient
pack
persist
ref
resource
statusText
style
tooltip
tooltipText
top
width

Inherited from Element:

addEventListener
appendChild
attributes
childNodes
cloneNode
dispatchEvent
firstChild
getAttribute
getAttributeNS
getAttributeNode
getAttributeNodeNS
getElementsByTagName
getElementsByTagNameNS
hasAttribute
hasAttributeNS
hasAttributes
hasChildNodes
insertBefore
isSupported
lastChild
localName
namespaceURI
nextSibling
nodeName
nodeType
nodeValue
normalize
ownerDocument
parentNode
prefix
previousSibling
removeAttribute
removeAttributeNS
removeAttributeNode
removeChild
removeEventListener
replaceChild
setAttribute
setAttributeNS
setAttributeNode
setAttributeNodeNS
tagName

accessKey

Gets and sets the value of the accesskey attribute.

accessible

Type: nsIAccessible

Returns the accessibility object for the listitem.

checked

Type: boolean

For checkbox type listitems, indicates whether the listitem is checked or not. You can change the checked property to change the state of the listitem. A CheckboxStateChange event will be sent to the listitem when it is changed either via the checked property or changed by the user.

control

Type: listbox element

A reference to the listitem's containing listbox.

crop

Type: string

Gets and sets the value of the crop attribute.

current

Type: boolean

Gets and sets the value of the current attribute.

disabled

Type: boolean

Gets and sets the value of the disabled attribute.

disabled

Type: boolean

Indicates whether the listitem is disabled or not. If this attribute is set to true, the listitem is disabled. This is usually drawn with the text in grey. If the listitem is disabled, it does not respond to user actions. The element cannot be focused and the command event will not fire. The element will still respond to mouse events. To enable the listitem, leave the attribute out entirely as opposed to setting the value to false.

image

Type: image URL

Gets and sets the value of the image attribute.

label

Type: string

Gets and sets the value of the label attribute.

selected

Type: boolean

Gets and sets the value of the selected attribute.

tabIndex    Mozilla 1.8

Type: integer

Gets and sets the value of the tabindex attribute.

value

Type: string

Gets and sets the value of the value attribute.


Copyright (C) 1999 - 2004 XulPlanet.com