jQuery remove() 方法jQuery remove() 方法删除被选元素及其子元素。实铲耻雁例$(document).ready(function(){ $("button").click(function(){ $("#div1").remove(); });});This is some text in the div.This is a paragraph in the div.This is another paragraph in the div.删除 div 元素
jQuery empty() 方法jQuery empty() 方法删除被选元素的子元素。实例$(document).ready(function(){ $("button").click(function(){ $("#div1").empty(); });});This is some text in the div.This is a paragraph in the div.This is another paragraph in the div.清空 div 元素
过滤被删除的元素jQuery remove() 方法也可接受一个参数,允许您对被删元素进爬醒行过滤。该参数可以是任何 jQuery 选择器的语法。下面的例子删缝蕉除 的所有 元素:$(document).ready(function(){ $("button").click(function(){ $("p").remove(".italic"); });});This is a paragraph in the div.This is another paragraph in the div.This is another paragraph in the div.删除 的所有 p 元素
标签:jQuery