Home>Article>Web Front-end> How to delete html in javascript

How to delete html in javascript

藏色散人
藏色散人 Original
2021-05-19 11:11:57 5711browse

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
   

被控制的目标元素

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
     

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

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!

Statement:
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