Jquery scroll window to top bottom and absolute positions

Recently i have posted how to make Social share buttons in asp.net, Making slider of html content with pagination in jquery , javascript close current window without prompt in ie , Select all div text in single click in JavaScript and now i am going to explain how to scroll window from jquery and make functionality like Scroll To Top, Scroll To Bottom, Scroll To An Absolute Position or just to a control from jquery.

below is the code for scrolling window through jquery -

this will scroll you to the top of the page with a good animated way, change the id according to you link of scroll to top.
$("#ancScrolltoTop").click(function () {
    $('html,body').animate({ scrollTop: 0 }, "slow");
});



this will scroll you to the bottom of the page, change the id according to you link of scroll to bottom.
$("#ancScrollToBottom").click(function () {
    $("html, body").animate({ scrollTop: $(document).height() }, "slow");
});


this will scroll you to a div control (having id dvMain), change the id's according to you link of scroll to a control.
$("#ancScrollToControl").click(function () {
    $('html,body').animate({ scrollTop: $("#dvMain").offset().top}, "slow");
});


Recent Article