Reputation: 9959
I use the following in order scrolling to top. How could i edit it so the top is set by a div tag?
var pageRequestManager = Sys.WebForms.PageRequestManager.getInstance();
pageRequestManager.add_endRequest(function() {
$('html, body').animate({ scrollTop: 0 }, 'slow');
});
Upvotes: 5
Views: 9095
Reputation: 236002
You need to use .offset()
to get the correct position value like:
$('html, body').animate({ scrollTop: $('#div').offset().top }, 'slow');
.offset
returns the current position of an element relative to the document.
References: .position(), .offset()
Upvotes: 8
Reputation: 11068
This is nice, as well:
http://plugins.jquery.com/project/ScrollTo
Upvotes: 0