我想bottom
在页面加载时将div滚动到页面底部,但也想在需要时向上滚动到如何在没有动画的情况下将其存档?echo "<div id='bottom'><p><b>$from_username</b><br />$message</p></div>";
<script>
function scrollpage() {
function f()
{
window.scrollTo(0,i);
if(status==0) {
i=i+40;
if(i>=Height){ status=1; }
}
setTimeout( f, 0.01 );
}f();
}
var Height=document.documentElement.scrollHeight;
var i=1,j=Height,status=0;
scrollpage();
</script>
这就是到目前为止,我能够自动向下滚动,但是在需要时却无法向上滚动,如果我想向上滚动,该怎么办?
滚动到页面加载(jQuery)上Div的底部,这是我在其中找到为您提供所需代码的地方。
<script>
$( document ).ready(function() {
var d = $('#div1');
d.scrollTop(d.prop("scrollHeight"));
console.log("at the bottom!");
});
</script>
</head>
<body>
<p>top</p>
<div style="max-height: 200px;">
<div id='div1' style='background-color:grey;width:200px;overflow:scroll;overflow-x:hidden;max-height:200px;'>
<p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p></div>
</div>
<p>bottom</p>
<p>text under the div</p>
</body>
</html>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句