jquery内容过滤器
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="jquery-3.3.1.js"></script>
<script>
$(function () {
$('#btn').click(function () {
//包含ha内容的层
//$('div:contains(ha)').css('fontSize', '20px');
//空层
//$('div:empty').css('backgroundColor', 'pink');
//层里面含有a标签
$('div:has(a)').css('backgroundColor', 'pink');
})
})
</script>
<style>
div{
width:300px;
height:200px;
border:1px solid red;
margin:50px;
}
</style>
</head>
<body>
<input type="button" name="name" value="显示效果" id="btn" />
<div>
hahha
</div>
<div>
heihei
</div>
<div></div>
<div>
<a href="http://www.baidu.com">content</a>
</div>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="jquery-3.3.1.js"></script>
<script>
$(function () {
$('#btn').click(function () {
//包含ha内容的层
//$('div:contains(ha)').css('fontSize', '20px');
//空层
//$('div:empty').css('backgroundColor', 'pink');
//层里面含有a标签
$('div:has(a)').css('backgroundColor', 'pink');
})
})
</script>
<style>
div{
width:300px;
height:200px;
border:1px solid red;
margin:50px;
}
</style>
</head>
<body>
<input type="button" name="name" value="显示效果" id="btn" />
<div>
hahha
</div>
<div>
heihei
</div>
<div></div>
<div>
<a href="http://www.baidu.com">content</a>
</div>
</body>
</html>