开发者

jQuery jump to id (no animation)

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();
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜