日期:2014-05-16 浏览次数:20373 次
<ol id="orderedlist2"> <li>First element, second list</li> <li>Second element, second list</li> <li>Third element, second list</li> <li>Li with child ul <ul> <li>Child One<a href="#">123</a></li> <li>child two</li> </ul> </li> </ol>
$(document).ready(function() { $("li").not("[ul]").css("border","1px solid black"); });
$("#orderedlist2 > li:not(:has(ul))").css("border","1px solid black");
------解决方案--------------------
$("#orderedlist2 > li").not(":has(ul)").css("border","1px solid black"); // 或者 $("#orderedlist2 > li").filter(function(){ return $(this).has("ul").length === 0 ? true : false; }).css("border","1px solid black");