案例: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
  var x;
7
  $("#btn1").click(function(){
8
    x=$("p").detach();
9
  });
10
  $("#btn2").click(function(){
11
    $("body").prepend(x);
12
  });
13
});
14
</script>
15
</head>
16
<body>
17
<p>这是一个段落。</p>
18
<button id="btn1">删除 p 元素</button>
19
<button id="btn2">恢复 p 元素</button>
20
</body>
21
</html>
22