($("ul").has("li").length ? "Yes" : "No") + "</li>") ????
<!DOCTYPE html>
<html>
<head>
<style>
.full { border: 1px solid red; }
</style>
<script type="text/javascript" src="../js/jquery-2.1.4.js"></script>
</head>
<body>
<ul>
<li>Does the UL contain an LI?</li>
</ul>
<script>
$("ul").append("<li>" + ($("ul").has("li").length ? "Yes" : "No") + "</li>");
//$("ul").has("li").length是不是强制转换布尔值。
$("ul").has("li").addClass("full");
console.log($("ul").has("li").length)
</script>
</body>
</html>