<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>判断</title>
<script type="text/javascript" src="../js/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
$(function(){
if($("p").has("span.bg")){
// 无效,不能使用this
// $(this).css("background","#ff0");
$("p").has("span.bg").css("background","#ff0");
};
});
</script>
</head>
<body>
<p><span class="bg">春眠不觉晓</span></p>
<p>处处闻啼鸟</p>
<p><span>夜来风雨声</span></p>
<p>花落知多少</p>
</body>
</html>
判断
最新推荐文章于 2023-03-20 10:25:09 发布