Script adds id
for block, gives:
<div id="some">Text</div>
After that page should jump for t开发者_Go百科hat id
, without animation, just like we have target #some
on current page link.
How to do this?
Thanks.
Try this:
document.getElementById('some').scrollIntoView(true);
Do you just mean linking "old school" like #some
For example
<a href="#some"></a>
Done in JS with
location.href = "#some";
Like this:
location.href = "#some";
$('a[href^="#"]').click(function() {
$('html,body').animate({ scrollTop: $(this.hash).offset().top});
return false;
e.preventDefault();
});
精彩评论