案例:jQuery案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
  <style>
5
    .full { border: 1px solid red; }
6
  </style>
7
  <script type="text/javascript" src="/js/jquery.js"></script>
8
</head>
9
10
<body>
11
<ul><li>Does the UL contain an LI?</li></ul>
12
13
<script>
14
  $("ul").append("<li>" + ($("ul").has("li").length ? "Yes" : "No") + "</li>");
15
  $("ul").has("li").addClass("full");
16
</script>
17
18
</body>
19
</html>
20