<html>
<head>
</head>
<body>
<div style="border:1px solid black;width:200px;height:200px;overflow:auto">
This is some text1. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text2. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text3. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text4. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text5. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text6. This is some text. This is some text. This is some text. This is some text. This is some text.
</div>
<button class="btn1">把 scroll top offset 设置为 100px</button>
<br />
<button class="btn2">获得 scroll top offset</button>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$( ".btn1" ).click(function(){
$( "div" ).animate( {scrollTop : 100 },1000 );
});
$( ".btn2" ).click(function(){
alert( $( "div" ).offset().top+"px" );
});
});
</script>
</body>
</html>
<head>
</head>
<body>
<div style="border:1px solid black;width:200px;height:200px;overflow:auto">
This is some text1. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text2. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text3. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text4. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text5. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text6. This is some text. This is some text. This is some text. This is some text. This is some text.
</div>
<button class="btn1">把 scroll top offset 设置为 100px</button>
<br />
<button class="btn2">获得 scroll top offset</button>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$( ".btn1" ).click(function(){
$( "div" ).animate( {scrollTop : 100 },1000 );
});
$( ".btn2" ).click(function(){
alert( $( "div" ).offset().top+"px" );
});
});
</script>
</body>
</html>