案例:jQuery案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript" src="/js/jquery.js"></script>
4
<script type="text/javascript">
5
x=0;
6
$(document).ready(function(){
7
  $("div").scroll(function() {
8
    $("span").text(x+=1);
9
  });
10
  $("button").click(function(){
11
    $("div").scroll();
12
  });
13
});
14
</script>
15
</head>
16
<body>
17
<p>请试着滚动 DIV 中的文本:</p>
18
<div style="width:200px;height:100px;overflow:scroll;">text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. 
19
<br /><br />
20
text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text.</div>
21
<p>滚动了 <span>0</span> 次。</p>
22
<button>触发窗口的 scroll 事件</button>
23
</body>
24
</html>
25