案例: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
  $("#btn1").click(function(){
7
    $("div").data("greeting", "Hello World");
8
  });
9
  $("#btn2").click(function(){
10
    alert($("div").data("greeting"));
11
  });
12
});
13
</script>
14
</head>
15
<body>
16
<button id="btn1">把数据添加到 div 元素</button><br />
17
<button id="btn2">获取已添加到 div 元素的数据</button>
18
<div></div>
19
</body>
20
</html>
21
22