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

Detailed explanation of jQuery remove() filtering deleted elements

小云云
Release: 2018-01-01 10:20:08
Original
1585 people have browsed it

This article introduces jQuery remove() to filter deleted elements through example code. The jQuery remove() method also accepts a parameter, allowing you to filter deleted elements. Friends who need it can refer to it. I hope it can Help everyone.

The jQuery remove() method also accepts a parameter, allowing you to filter deleted elements.

This parameter can be any jquery selector syntax.

The following example deletes all <p> elements with class="italic":


##

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
 $("button").click(function(){
  $("p").remove(".italic");
 });
});
</script>
</head>
<body>
<p>这是一个段落。</p>
<p class="italic"><i>这是另外一个段落。</i></p>
<p class="italic"><i>这是另外一个段落。</i></p>
<button>移除所有 class="italic" 的 p 元素。</button>
</body>
</html>
Copy after login

Related recommendations:


The difference between remove() and detach() in jquery

Analysis of the remove() and detach() functions in jquery Differences in usage

<p> Detailed explanation of jQuery.remove() function usage

The above is the detailed content of Detailed explanation of jQuery remove() filtering deleted elements. 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
Popular Tutorials
More>
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!