aboutsummaryrefslogtreecommitdiff
path: root/files/ja/archive/mozilla/xul/method/removeitemat/index.html
blob: f75d24c21d921ca1f2ea9535db2e0591fcca4a07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---
title: removeItemAt
slug: Archive/Mozilla/XUL/Method/removeItemAt
tags:
  - XUL Methods
  - XUL Reference
translation_of: Archive/Mozilla/XUL/Method/removeItemAt
---
<div class="noinclude"><span class="breadcrumbs XULRefMeth_breadcrumbs">« <a href="/ja/docs/XUL_Reference" title="/ja/docs/XUL_Reference">XUL リファレンス HOME</a></span></div>

<dl>
  <dt><span id="m-removeItemAt"><code><a href="https://developer.mozilla.org/ja/docs/Mozilla/Tech/XUL/Method/removeItemAt">removeItemAt( index )</a></code></span></dt>
  <dd>戻り値の型: <em>要素</em></dd>
  <dd>要素内の指定した index の子項目を削除します。このメソッドは削除した項目を返します。</dd>
</dl>

<div class="noinclude">

<pre class="brush:js">&lt;script type="text/javascript"&gt;
function removeSelectedItem() {
  var myListBox = document.getElementById('myListBox');

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

&lt;button label="Remove selected item" oncommand="removeSelectedItem()" /&gt;

&lt;listbox id="myListBox"&gt;
  &lt;listitem label="Alpha" /&gt;
  &lt;listitem label="Beta" /&gt;
  &lt;listitem label="Oscar" /&gt;
  &lt;listitem label="Foxtrot" /&gt;
&lt;/listbox&gt;
</pre>

  <h2 id="See_also" name="See_also">関連情報</h2>
  <ul>
<li><a href="/ja/docs/XUL/Method/removeAllItems"><code>removeAllItems()</code></a><a href="/ja/docs/XUL/Method/appendItem"><code>appendItem()</code></a><a href="/ja/docs/XUL/Method/insertItemAt"><code>insertItemAt()</code></a></li>
</ul>

</div>