How to delete html in javascript

藏色散人
Release: 2023-01-06 11:14:10
Original
5676 people have browsed it

Javascript method to delete html: 1. Delete nodes through removeChild; 2. Delete the option at the specified index through remove; 3. Delete rows and cells in the table through deleteRow and deleteCell.

How to delete html in javascript

The operating environment of this article: windows7 system, javascript1.8.5&&html5 version, DELL G3 computer

JavaScript delete HTML element

1-Delete node

  • removeChild(oldNode): Delete oldChild child node
   

被控制的目标元素

Copy after login

RESULT

1

2How to delete html in javascript
How to delete html in javascript

2- Remove the option of the list box drop-down menu

  • remove(long index): Remove the option at the specified index
     
Copy after login

Result
How to delete html in javascript

3-Delete rows or cells of the table

  • deleteRow(long index): Delete the row at index index in the table
  • deleteCell(long index) : Delete the cell at the index of a row
  
删除第行, 第
java
1 2
3 4
5 6
Copy after login

Result
How to delete html in javascript

Recommended study: "javascript Advanced Tutorial

The above is the detailed content of How to delete html in javascript. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!