JavaScript remove()
remove方法可以刪除節點自身。
語法結構:
[JavaScript] 純文字檢視 複製程式碼elementNodeReference.remove();
瀏覽器支援:
(1).IE瀏覽器不支援此方法。
(2).edge瀏覽器支援此方法。
(3).谷歌瀏覽器支援此方法。
(4).opera瀏覽器支援此方法。
(5).火狐瀏覽器支援此方法。
(6).safria瀏覽器支援此方法。
程式碼例項:
[HTML] 純文字檢視 複製程式碼執行程式碼<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style type="text/css"> ul li{ width:150px; height:20px; line-height:20px; list-style:none; } </style> <script type="text/javascript"> window.onload=function(){ let obt=document.getElementById("bt"); let obox=document.getElementById("box"); let lis = obox.getElementsByTagName("li"); obt.onclick=function(){ lis[1].remove(); } } </script> </head> <body> <ul id="box"> <li>螞蟻部落一</li> <li>螞蟻部落二</li> <li>螞蟻部落三</li> <li>螞蟻部落四</li> </ul> <input type="button" id="bt" value="檢視效果"/> </body> </html>
點選按鈕可以刪除li元素集合中的第二個元素。
相關文章
- JavaScript select remove()JavaScriptREM
- DataTransferItemList.remove()REM
- Remove Element 解答REM
- [leetcode]remove-elementLeetCodeREM
- 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
- 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
- Leetcode 19 Remove Nth Node From End of ListLeetCodeREM
- [LeetCode] 2487. Remove Nodes From Linked ListLeetCodeREM
- LeetCode 83. Remove Duplicates from Sorted ListLeetCodeREM
- Remove Duplicate Letters 刪除重複元素REM
- [leetcode]remove-duplicates-from-sorted-array-iiLeetCodeREM
- 【程式碼優化】List.remove() 剖析優化REM
- Leetcode Remove Duplicates型別題目 (python)LeetCodeREM型別Python
- E - Remove Pairs(狀壓dp+博弈論)REMAI
- fcpx影片去閃爍外掛:Remove FlickeREM
- [LeetCode] 80. Remove Duplicates from Sorted Array IILeetCodeREM
- js中dom節點刪除remove方法JSREM
- 執行ArrayList的remove(object)方法拋異常?REMObject
- 沒什麼技術含量的Remove Before FlightREM
- SciTech-Mathmatics-ImageProcessing-Remove the Background from an image using Python?REMPython
- 那些年走過ArrayList迴圈remove的坑REM
- 轉載 個人用 How To Remove Docker Images, Containers, and VolumesREMDockerAI
- Babylon-AST初探-程式碼更新&刪除(Update & Remove)ASTREM
- LeetCode 1209. Remove All Adjacent Duplicates in String II 有坑LeetCodeREM