当某个节点用remove方法删除后,该节点所包含的所有后代节点将同时被删除。这个方法的返回值是一个指向已被删除的节点的引用。

另外remove()方法也可以通过传递参数来选择性地删除元素。

Home  >  Article  >  Web Front-end  >  jQuery DOM operation deletion node example_jquery

jQuery DOM operation deletion node example_jquery

WBOY
WBOYOriginal
2016-05-16 17:05:25823browse

If an element is redundant in the document, it should be removed. jQuery provides two methods for deleting nodes, the remove() method and the empty() method.

1. remove():

Copy code The code is as follows:

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>



Insert title here




What is your favorite fruit?



  • Apple
  • orange

  • banana





jQuery DOM operation deletion node example_jquery
When a node is deleted using the remove method, all descendant nodes contained in the node will be deleted at the same time. delete. The return value of this method is a reference to the deleted node.

In addition, the remove() method can also selectively delete elements by passing parameters.
Copy code The code is as follows:



jQuery DOM operation deletion node example_jquery
View the page source code at this time:
jQuery DOM operation deletion node example_jquery
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