<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<title>判断元素为空时隐藏</title>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
....
</script>
<style>
.box{
width: 50px;
height: 50px;
background: red;
}
</style>
<body>
<div class="box">
<h1>111</h1>
</div>
<div class="box">
<h1>222</h1>
</div>
<div class="box">
<h1>333</h1>
</div>
<div class="box">
<h1></h1>
</div>
</body>
</html>
判断如果h1内容为空时,隐藏该box~~试了一下,都没实现
$("h1:empty").hide()
http://www.jquery123.com/empty-selector/
然后把你的样式中
.box
改成.box h1
,我想就应该能够满足你的需求吧……