开发者

how to replicate href="...#something" with jquery

It's hard to describe the whole problem but to make a long story short, I can't use href="...#something" but I need this functionality. Is there a way to replicate it with jquery? So I want to have something like this onclic开发者_运维百科k="$('div#something').jumpThere();" but I don't know the exact name of the function. Could you please let me know whether jquery has such function and if yes, how it is called.


You don't need jQuery

window.location.hash = '#something';

should do it.


Difficult. But i would look into on click, getting the .position() of the element you want to go to. Then setting the window.scrollTop to that value (this will only work in some situations). That would be where I would start: .position() and window.scrollTop

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜