【发布时间】:2017-04-13 20:31:10
【问题描述】:
我正在这样的 div 中加载网站:
<script type="text/javascript">
$(document).ready(function(){
jQuery('#pagecontainer').load('http://www.example.com' );
})
</script>
<div id="pagecontainer" /></div>
加载的站点包含一个 id="test" 的 DIV。 到目前为止一切顺利。
但是是否可以将页面自动滚动到该 DIV?
下面的代码不起作用,我认为是因为它无法在加载的站点中找到 DIV。
$(function(){
$('html, body').animate({
scrollTop: $('#test').offset().top
}, 2000);
return false;
});
谢谢!
【问题讨论】:
标签: jquery autoscroll