jquery遍历方法,搜索段落中的后代元素,进行统一的修改。
例:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
</head>
<body>
<p><span>Hello</span>, how are you?</p>
<p>Me? I‘m <span>good</span>.</p>
<script>
$("p").find("span").css(‘color‘,‘red‘);
</script>
</body>
</html>
定义P元素中所有的span元素的color为red
时间: 2024-11-05 12:01:57