尝试将背景颜色添加到我所有的UL的不包含一个链接使用jQuery选择*不*包含一个链接列表项
HTML元素:
<ul id="list">
<li><a href="http://google.com/">Google</a></li>
<li><a href="http://yahoo.com/">Yahoo</a></li>
<li>Not a link</li>
<li><a href="http://live.com/">Live</a></li>
<li>Not a link</li>
</ul>
的Javascript:
$('#list li').css({'background': 'red'});
但改变所有的人 - http://jsbin.com/pusogihuvi/1/edit?html,js,output
的[获取没有jQuery的子节点的所有元素]可能重复(http://stackoverflow.com/questions/11061594/get-all-elements-without-child-node-in-jquery) – 2014-11-03 16:08:01
[jQuery selectors - 找到没有指定属性的对象]的可能重复(http://stackoverflow.com/questions/1969141/jquery-selectors-find-对象 - 无 - 技术规格ED-属性) – 2014-11-03 16:38:18