答:使用jQueryremove()方法
您可以简单地使用jQueryremove()方法从DOM中删除元素。此方法将删除匹配的元素以及其中的所有内容。
下面的示例将向您展示如何从DOM中完全删除一个段落。
例试试这个代码»
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Remove Elements from DOM</title>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
    $(document).ready(function(){
        $("button").click(function(){
            $("p").remove(); 
        });
    });
</script>
</head>
<body>
    <button>Remove paragraph</button>
    <h1>This is a heading</h1>
    <p>This is a paragraph.</p>
</body> 
</html>
                    	
                    	
                    	  
                    	    
                    	    
                    	    
                    	 
    如果您觉得本文的内容对您的学习有所帮助:
     
                    	
                    	   
                    	   关键字:
jQuery