<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <script src="../../Scripts/jquery-3.4.1.min.js"></script> <script src="delete.js"></script> </head> <body> <div id="div" style="height:200px;width:200px;border:1px solid black;background-color:cadetblue"> hello <p>hello world</p> <p>hello</p> </div> <button id="btndelete">删除</button> </body> </html>
//常用的两种移除方式 $(document).ready(function () { $("#btndelete").click(function () { $("p").remove();//全部删除 $("#div").remove();//全部删除 $("#div").empty();//删除子元素整个内容 }); });
标签:jQuery,function,删除,remove,HTML,hello From: https://www.cnblogs.com/Mandy-ZQ-Ma/p/17357252.html