实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js">
5
</script>
6
<script>
7
x=0;
8
$(document).ready(function(){
9
  $("div").scroll(function(){
10
    $("span").text(x+=1);
11
  });
12
});
13
</script>
14
</head>
15
<body>
16
17
<p>Try the scrollbar in the div</p>
18
<div style="border:1px solid black;width:200px;height:100px;overflow:scroll;">In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.
19
<br><br>
20
'Whenever you feel like criticizing anyone,' he told me, just remember that all the people in this world haven't had the advantages that you've had.'</div>
21
<p>Scrolled <span>0</span> times.</p>
22
23
</body>
24
</html>