node2:/var/www/html/js#cat h28.html
<div>
<p>aaaaaaaaaaaa</p>
<p>bbbbbbbbbbbb</p>
<p>cccccccccccc</p>
<p>dddddddddddd</p>
<p>eeeeeeeeeee</p>
<p>fffffffffff</p>
<p>gggggggggggg</p>
</div>
<div>
<span>11111111</span>
</div>
<div>2222222222222</div>
<script type="text/javascript" src="jquery-2.2.2.min.js"></script>
<script type="text/javascript" src="h28.js"></script>
node2:/var/www/html/js#cat h28.js
$('div:has(span)').css("background","red");
node2:/var/www/html/js#
它会选择相对于span的所有div父元素