aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/htmlselectelement/remove/index.md
blob: 48e64849436400b0629e16a51532f6cbc15cc2ff (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
title: HTMLSelectElement.remove()
slug: Web/API/HTMLSelectElement/remove
tags:
  - API
  - HTML DOM
  - HTMLSelectElement
  - メソッド
  - リファレンス
browser-compat: api.HTMLSelectElement.remove
translation_of: Web/API/HTMLSelectElement/remove
---
{{ APIRef("HTML DOM") }}

**`HTMLSelectElement.remove()`** メソッドは、この select 要素の選択肢の集合から指定された位置の要素を削除します。

## 構文

```js
collection.remove(index);
```

### 引数

- `index` は long 値で、集合から削除する {{ domxref("HTMLOptionElement") }} の位置を表します。この位置の要素が見つからなかった場合は、このメソッドは効果がありません。

## 例

```js
var sel = document.getElementById("existingList");
sel.remove(1);

/*
  以下の select オブジェクトが既にあるとします。

  <select id="existingList" name="existingList">
    <option value="1">Option: Value 1</option>
    <option value="2">Option: Value 2</option>
    <option value="3">Option: Value 3</option>
  </select>

  以下のように変化します。

  <select id="existingList" name="existingList">
    <option value="1">Option: Value 1</option>
    <option value="3">Option: Value 3</option>
  </select>
*/
```

## 仕様書

{{Specifications}}

## ブラウザーの互換性

{{Compat}}

## 関連情報

- {{ domxref("Element.remove") }} は、{{ domxref("HTMLSelectElement") }} 上で remove が引数無しに呼び出された場合に呼び出されるメソッドです。
- 実装先の {{domxref("HTMLSelectElement") }}