Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.
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);
    }
}
function removeAllItems(){

    var myListBox = document.getElementById('myListBox');
    var count = myListBox.itemCount;
    while(count-- > 0){
        myListBox.removeItemAt(0);
    }
}
</script>

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

See also

Document Tags and Contributors

 Contributors to this page: Sheppy, trevorh, ethertank, tomgcoleman, Marsf, Mgjbot, Ptak82, Pmash, Dria
 Last updated by: Sheppy,