Joe*_*oth 1 html javascript jquery
使用溢出滚动div的最佳方法是什么:单击某个锚点时自动按某个像素或某个百分比?HTML非常简单:
<style>
#container{
height:250px;
overflow:auto;
</style>
<div id="container">
<p>Lots of Content</p>
</div>
<a href="#" id="scrolldiv">Scroll Down</a>
Run Code Online (Sandbox Code Playgroud)
当我单击上面的锚点时,我想将该div放在一定数量的像素上方,比如30px.我希望jQuery内置一些简单的东西.
$('#scrolldiv').click(function(e){
var current = $('#container').scrollTop();
$('#container').scrollTop(current + 30);
e.preventDefault();
});?
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3425 次 |
| 最近记录: |