mozilla

Compare Revisions

removeItemAt

Change Revisions

Revision 85335:

Revision 85335 by Dria on

Revision 85336:

Revision 85336 by Pmash on

Title:
removeItemAt
removeItemAt
Slug:
XUL/Method/removeItemAt
XUL/Method/removeItemAt
Tags:
"XUL Reference", "XUL Methods"
"XUL Reference", "XUL Methods"
Content:

Revision 85335
Revision 85336
tt21    <div class="noinclude">
22      <pre>
23&lt;script language="javascript"&gt;
24function removeSelectedItem(){
25 
26    var myListBox = document.getElementById('myListBox');
27 
28    if(myListBox.selectedIndex == -1){
29        return; // no item selected so return
30    }else{
31        myListBox.removeItemAt(myListBox.selectedIndex);
32    }
33}
34&lt;/script&gt;
35 
36&lt;button label="Remove selected item" oncommand="removeSelected
 >Item()"/&gt;
37&lt;listbox id="myListBox"&gt;
38  &lt;listitem label="Alpha"/&gt;
39  &lt;listitem label="Beta"/&gt;
40  &lt;listitem label="Oscar"/&gt;
41  &lt;listitem label="Foxtrot"/&gt;
42&lt;/listbox&gt;
43</pre>
44      <h3 name="See_also">
45        See also
46      </h3>
47      <p>
48        <a href="en/XUL/Method/removeAllItems">removeAllItems()</
 >a>, <a href="en/XUL/Method/appendItem">appendItem()</a> and <a hr
 >ef="en/XUL/Method/insertItemAt">insertItemAt()</a>
49      </p>
50    </div>

Back to History