【发布时间】:2015-09-17 00:40:47
【问题描述】:
我有这段代码,当您打开链接时,它会滚动到该页面上的特定 div。
collection.html
<a id='about' href="index.html">about</a>
index.html
<div id='#moreInfo>contents here</div>
<script>
$(document).ready(function(){
$('html, body').animate({
scrollTop: $("#moreInfo").offset().top
}, 1000);
})
</script>
我的问题是每当我加载 index.html 时,它总是滚动到 moreInfo div。我想要的是当我在 collection.html 上并单击 about 链接时,它将重定向到 index.html 然后滚动顺利到 moreInfo div。
我将不胜感激。
【问题讨论】:
标签: javascript jquery html autoscroll