Visit Mozilla.org

XUL:Method:removeItemAt

From MDC

« XUL Reference home

removeItemAt( index )
Return type: element
Removes the child item in the element at the specified index. The method returns the removed item.
<script language="javascript">
function removeSelectedItem(){

    var myListBox = document.getElementById('myListBox');

    if(myListBox.selectedIndex == -1){
        return; // no item selected so return
    }else{
        myListBox.removeItemAt(myListBox.selectedIndex);
    }
}
</script>

<button label="Remove selected item" oncommand="removeSelectedItem()"/>
<listbox id="myListBox">
  <listitem label="Alpha"/>
  <listitem label="Beta"/>
  <listitem label="Oscar"/>
  <listitem label="Foxtrot"/>
</listbox>

[edit] See also

removeAllItems(), appendItem() and insertItemAt()