案例: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
  $("p").live("click",function(){
7
    $(this).slideToggle();
8
  });
9
  $("button").click(function(){
10
    $("<p>This is a new paragraph.</p>").insertAfter("button");
11
  });
12
});
13
</script>
14
</head>
15
<body>
16
<p>这是一个段落。</p>
17
<p>点击任意 p 元素会令其消失。包括本段落。</p>
18
<button>在本按钮后面插入新的 p 元素</button>
19
<p><b>注释:</b>通过使用 live() 方法而不是 bind() 方法,新的 p 元素同样会在点击时消失。</p>
20
</body>
21
</html>
22