案例:jquery案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script src="/js/jquery-1.11.1.min.js"></script>
5
<script>
6
$(document).ready(function(){
7
  $("#btn1").click(function(){
8
    $("#test1").text(function(i,origText){
9
      return "Old text: " + origText + " New text: Hello world! (index: " + i + ")"; 
10
    });
11
  });
12
13
  $("#btn2").click(function(){
14
    $("#test2").html(function(i,origText){
15
      return "Old html: " + origText + " New html: Hello <b>world!</b> (index: " + i + ")"; 
16
    });
17
  });
18
19
});
20
</script>
21
</head>
22
23
<body>
24
<p id="test1">这是<b>粗体</b>文本。</p>
25
<p id="test2">这是另一段<b>粗体</b>文本。</p>
26
<button id="btn1">显示旧/新文本</button>
27
<button id="btn2">显示旧/新 HTML</button>
28
</body>
29
</html>
30