
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<script src="js/jquery.js" ></script>
<script>
window.onload = function(){
document.getElementById('btnok').onclick = function(){
//1.匹配内容包含 “虾” 的li借点
//$('li:contains(虾)').css('backgroundColor','red');
//2.匹配空元素
//$('li:empty()').html('庄家通杀');
//3.匹配包含span元素的li节点
//$('li:has(span)').css('backgroundColor','red');
//4.匹配不为空的元素
$('li:parent()').html('想啥呢?继续敲代码');
}
}
</script>
</head>
<body>
<input type="button" id="btnok" value="匹配" />
<hr/>
<ul>
<li>鱼</li>
<li></li>
<li>虾</li>
<li>蟹</li>
<li><span>庄家通杀</span></li>
</ul>
</body>
</html>