JavaScript select remove()
此方法可以從下拉選單中刪除一個選項。
語法結構:
[JavaScript] 純文字檢視 複製程式碼select.remove(index)
引數解析:
(1).select:select物件。
(2).index:必需,規定要刪除的選項的索引值。
程式碼例項如下:
[HTML] 純文字檢視 複製程式碼執行程式碼<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <script type="text/javascript"> window.onload=function(){ let oSelect=document.getElementById("st"); oSelect.remove(2); } </script> </head> <body> <select id="st" name="myselect"> <option value="1">螞蟻部落一</option> <option value="2">螞蟻部落二</option> <option value="3">螞蟻部落三</option> <option value="4">螞蟻部落四</option> </select> </body> </html>
可以刪除索引值為2的option項,也就是第三項。
相關文章
- JavaScript remove()JavaScriptREM
- JavaScript select add()JavaScript
- JavaScript select typeJavaScript
- JavaScript select valueJavaScript
- JavaScript select multipleJavaScript
- JavaScript select 事件JavaScript事件
- JavaScript select options 集合JavaScript
- JavaScript select text 屬性JavaScript
- JavaScript select size 屬性JavaScript
- JavaScript select length 屬性JavaScript
- JavaScript操作select控制元件JavaScript控制元件
- JavaScript動態操作select下拉選單JavaScript
- JavaScript新增和刪除select下拉項JavaScript
- DataTransferItemList.remove()REM
- Remove Element 解答REM
- [leetcode]remove-elementLeetCodeREM
- select 下拉框用 Select select = new Select (element) 方法失敗
- leetcode-27. Remove ElementLeetCodeREM
- Leetcode 27 Remove-ElementLeetCodeREM
- [LintCode/LeetCode] Remove Duplicate LettersLeetCodeREM
- swagger ui remove springboot pathsSwaggerUIREMSpring Boot
- openmesh - impl - Remove Duplicated VerticesREM
- [LeetCode] 402. Remove K DigitsLeetCodeREMGit
- Remove-duplicates-from-sorted-arrayREM
- Remove-duplicates-from-sorted-listREM
- c++的remove函式C++REM函式
- Java List的remove()方法陷阱JavaREM
- jQuery之empty()與remove()方法jQueryREM
- Linux select()Linux
- insert into select
- select for update
- select()APIAPI
- Leetcode 26 Remove Duplicates from Sorted ArrayLeetCodeREM
- C++ remove erase 用法淺析C++REM
- Check the existence of public synonyms Remove the public synonymsREM
- Leetcode 203. Remove Linked List ElementsLeetCodeREM
- LeetCode | 203. Remove Linked List ElementsLeetCodeREM
- select * 和 select 所有欄位的區別