CodeLab
Show Output
 
xxxxxxxxxx
20
 
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<meta charset="utf-8">
5
<title>jQuery Remove Elements from DOM</title>
6
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
7
<script>
8
    $(document).ready(function(){
9
        $("button").click(function(){
10
            $("p").remove(); 
11
        });
12
    });
13
</script>
14
</head>
15
<body>
16
    <button>Remove paragraph</button>
17
    <h1>This is a heading</h1>
18
    <p>This is a paragraph.</p>
19
</body> 
20
</html>
 

在微博、微信、公众号、小程序分享此示例。 如果您觉得有帮助,请给我们一个赞。