Bijay Rungta aka rungss's posterous, Spreading Knowledge..

Bijay Rungta aka rungss Spreading Knowledge..

« Back to posts
  • Viewed
    times
January 11, 2011

Scroll to the Top of a Div in an HTML Document in Javascript.

  • Edit
  • Delete
  • Tags
  • Autopost

You may sometime want your Brwoser to scroll to a part of the HTML Document.

Typically when you load some content uisng AJAX, you would want to srcroll to the element which was updated.

You can do this with the following javascript code.

document.scrollTo(0, document.getElementById('id-of-element').offsetTop);

Enjoy Coding.

Tweet
  • 0 responses
  • Like
  • Comment