From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/htmlselectelement/remove/index.html | 94 ++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 files/zh-cn/web/api/htmlselectelement/remove/index.html (limited to 'files/zh-cn/web/api/htmlselectelement/remove/index.html') diff --git a/files/zh-cn/web/api/htmlselectelement/remove/index.html b/files/zh-cn/web/api/htmlselectelement/remove/index.html new file mode 100644 index 0000000000..6cb7046a6e --- /dev/null +++ b/files/zh-cn/web/api/htmlselectelement/remove/index.html @@ -0,0 +1,94 @@ +--- +title: HTMLSelectElement.remove() +slug: Web/API/HTMLSelectElement/remove +translation_of: Web/API/HTMLSelectElement/remove +--- +
{{ APIRef("HTML DOM") }}
+ +

HTMLSelectElement.remove() 方法从一个 select 元素中删除指定序数的 option 元素。没有传参时为删除当前元素本身:ChildNode.remove()

+ +

语法

+ +
collection.remove(index);
+
+ +

参数

+ + + +
+
+ +

例子

+ +
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

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-select-remove', 'HTMLSelectElement.remove()')}}{{Spec2('HTML WHATWG')}}
{{SpecName('HTML5 W3C', 'forms.html#dom-select-remove', 'HTMLSelectElement.remove()')}}{{Spec2('HTML5 W3C')}}Is a snapshot of {{SpecName("HTML WHATWG")}}.
{{SpecName('DOM2 HTML', 'html.html#ID-33404570', 'HTMLSelectElement.remove()')}}{{Spec2('DOM2 HTML')}}
{{SpecName('DOM1', 'level-one-html.html#ID-33404570', 'HTMLSelectElement.remove()')}}{{Spec2('DOM1')}}Initial definition.
+ +

浏览器兼容性

+ + + +

{{Compat("api.HTMLSelectElement.remove")}}

+ +

参考

+ + + +

+ +

-- cgit v1.2.3-54-g00ecf