案例:jQuery案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript" src="/js/jquery.js"></script>
4
<script type="text/javascript">
5
$(document).ready(function(){
6
  $("button").click(function(){
7
    $("p").append(function(n){
8
      return "<b>This p element has index " + n + "</b>";
9
    });
10
  });
11
});
12
</script>
13
</head>
14
15
<body>
16
<h1>This is a heading</h1>
17
<p>This is a paragraph.</p>
18
<p>This is another paragraph.</p>
19
<button>在每个 p 元素的结尾添加内容</button>
20
</body>
21
</html>
22