Home > Web Front-end > JS Tutorial > body text

How to delete an html element node in javascript_javascript skills

WBOY
Release: 2016-05-16 16:25:26
Original
1119 people have browsed it

The example in this article describes how to use native javascript to delete a specified html element. Share it with everyone for your reference. The specific implementation method is as follows:

Copy code The code is as follows:





Script Home

<script><br> window.onload=function(){<br> var obt=document.getElementById("bt");<br> var odiv=document.getElementById("content");<br> obt.onclick=function(){<br> odiv.parentNode.removeChild(odiv);<br> }<br> }<br> </script>


Script Home



In native JavaScript, there is currently no way to delete the element itself. If you want to delete it, you can delete the specified child element through the removeChild() method of the parent node. The code is relatively simple. I won’t introduce it here. If you are interested Friends can refer to relevant information.

I hope this article will be helpful to everyone’s web programming based on JavaScript.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template