JAVA全系列 教程
3762个小节阅读:7092.7k
目录
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
选择器
DOM操作
Class操作 addClass() removeClass() toggleClass() hasClass()
文本操作 html() text() val()
属性操作 attr() removeAttr()
DOM 插入并包裹现有内容 .wrap() .unwrap() .wrapAll() .wrapInner()
DOM 插入现有元素内 .append() .prepend()
DOM 插入现有元素外 .after() .before()
DOM 移除
DOM 替换
CSS操作
事件处理
遍历
动画
从 DOM 树中删除元素
从DOM中移除集合中匹配元素的所有子节点
xxxxxxxxxx
<!DOCTYPE html>
<html>
<head>
<script src="./js/jquery-3.6.0.min.js"></script>
</head>
<body>
<p>
Hello, <span>Person</span> <a href="javascript:;">and person</a>
</p>
<script>
$("p").empty();
</script>
</body>
</html>
将匹配元素集合从DOM中删除
xxxxxxxxxx
<!DOCTYPE html>
<html>
<head>
<script src="./js/jquery-3.6.0.min.js"></script>
</head>
<body>
<p>Hello</p>
<script>
$("p").remove();
</script>
</body>
从 DOM 树中移除已有的内容并将其替换为新内容
用集合的匹配元素替换每个目标元素
xxxxxxxxxx
<!DOCTYPE html>
<html>
<head>
<script src="./js/jquery-3.6.0.min.js"></script>
</head>
<body>
<p>Hello</p>
<script>
$("<b>World</b>").replaceAll("p");
</script>
</body>
</html>
用提供的内容替换集合中所有匹配的元素
xxxxxxxxxx
<!DOCTYPE html>
<html>
<head>
<script src="./js/jquery-3.6.0.min.js"></script>
</head>
<body>
<p>Wrold</p>
<script>
$("p").replaceWith("<div>Hello</div>");
</script>
</body>
</html>
实时效果反馈
1. DOM操作中,如何把一个容器中的内容全部删除:
A empty()
B remove()
C replaceAll()
D replaceWith()
答案
1=>A