Home
Web Front-end
JS Tutorial
JavaScript deletes specified child element code example_javascript skills



JavaScript deletes specified child element code example_javascript skills
javascript
delete
Native javascript code example to delete specified sub-element:
This chapter introduces how to use native javascript to delete specified sub-elements.
Everyone knows that it is more convenient to use jquery to implement this function, but it is not troublesome to use native javascript. Let’s introduce it below.
For information about how jquery implements this function, please refer to the chapter jquery to delete specified child elements code examples.
Code example:
Copy code The code is as follows:
<script><br> window.onload=function(){<br> var obt=document.getElementById("bt");<br> var obox=document.getElementById("box");<br> var lis=obox.getElementsByTagName("li");<br> obt.onclick=function(){<br> obox.removeChild(lis[1]);<br> }<br> }<br> </script>
- Script House welcomes you, only by working hard can we have a better tomorrow.
- No one is a master from the beginning, they have to work hard.
- Every day is new, so cherish your time.