HTMLSelectElement.remove()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itโs been available across browsers since โจ2015ๅนด7ๆโฉ.
HTMLSelectElement.remove()
ๆนๆณไปไธไธช select ๅ
็ด ไธญๅ ้คๆๅฎๅบๆฐ็ option ๅ
็ด ใๆฒกๆไผ ๅๆถไธบๅ ้คๅฝๅๅ
็ด ๆฌ่บซ๏ผChildNode.remove()ใ
่ฏญๆณ
js
remove(index)
ๅๆฐ
index
ๆฏไป optionHTMLOptionElement
้ๅไธญ่ฆ็งป้คๅ ็ด ็ๅบๆฐใๅฆๆๅบๆฐๅฏนๅบ็ๅ ็ด ไธๅญๅจ๏ผ่ฐ็จ่ฟไธชๆนๆณๅฐฑๆฒกๆไปปไฝๆๆใ
ไพๅญ
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
Specification |
---|
HTML # dom-select-remove |
ๆต่งๅจๅ ผๅฎนๆง
Loadingโฆ
ๅ่
ChildNode.remove
๏ผๅฝๆฒกๆๅๆฐๆถHTMLSelectElement
่ฐ็จ็ๆฏ่ฟไธชๆนๆณHTMLSelectElement
ๅฎ็ฐไบ่ฟไธชๆนๆณใ