3

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 ?

Tran
  • 185
  • 2
  • 4
  • 14

1 Answers1

12
$(function() { // when the DOM is ready...
    //  Move the window's scrollTop to the offset position of #now
    $(window).scrollTop($('#now').offset().top);
});
visualidiot
  • 497
  • 3
  • 5