案例: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").scrollTop(100);
8
  });
9
  $(".btn2").click(function(){
10
    alert($("div").scrollTop()+" px");
11
  });
12
});
13
</script>
14
</head>
15
<body>
16
<div style="border:1px solid black;width:200px;height:200px;overflow:auto">
17
This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.
18
</div>
19
<button class="btn1">把 scroll top offset 设置为 100px</button>
20
<br />
21
<button class="btn2">获得 scroll top offset</button>
22
</body>
23
</html>
24