脚本id
为块添加,给出:
<div id="some">Text</div>
在该页面应该跳转id
之后,没有动画,就像我们#some
在当前页面链接上有目标一样。
这该怎么做?
谢谢。
试试这个:
document.getElementById('some').scrollIntoView(true);
你的意思是像#some这样链接“老派”吗
例如
<a href="#some"></a>
在 JS 中完成
location.href = "#some";
像这样:
location.href = "#some";
$('a[href^="#"]').click(function() {
$('html,body').animate({ scrollTop: $(this.hash).offset().top});
return false;
e.preventDefault();
});