最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Auto scroll to a div after finish loading. Use jquery - Stack Overflow

programmeradmin3浏览0评论

I have a div with id=now, this div is empty and do not have any css property (no width, no height, just a hidden div). I want when browser finish load the page, then scroll to this div immediately. User do not need to click on some thing.

Here is my html

<html>
<div>Long div Lorem ipsum</div>
<div id="now"></div>
<div>Long div Lorem ipsum</div>

How to do this with jquery ?

I have a div with id=now, this div is empty and do not have any css property (no width, no height, just a hidden div). I want when browser finish load the page, then scroll to this div immediately. User do not need to click on some thing.

Here is my html

<html>
<div>Long div Lorem ipsum</div>
<div id="now"></div>
<div>Long div Lorem ipsum</div>

How to do this with jquery ?

Share Improve this question asked Mar 7, 2012 at 10:25 TranTran 3152 gold badges5 silver badges15 bronze badges 2
  • Duplicate question - check this stackoverflow./questions/6677035/jquery-scroll-to-element – Sandeep G B Commented Mar 7, 2012 at 10:28
  • see in this post stackoverflow./questions/5284814/jquery-scroll-to-div – Luca Commented Mar 7, 2012 at 10:28
Add a ment  | 

1 Answer 1

Reset to default 12
$(function() { // when the DOM is ready...
    //  Move the window's scrollTop to the offset position of #now
    $(window).scrollTop($('#now').offset().top);
});
发布评论

评论列表(0)

  1. 暂无评论