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
1 Answer
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);
});