I want to put to the top bottom of the page which should scroll the page to the top. However I want the scrolling process to have animated effect. I think it is possible by using animate but have no idea how to ?
Please help. Thanks
I want to put to the top bottom of the page which should scroll the page to the top. However I want the scrolling process to have animated effect. I think it is possible by using animate but have no idea how to ?
Please help. Thanks
The way is pretty simple. Put a button at the bottom of the page and write an event something like this
$('#spnTop').on("click",function() {
$('html, body').animate({ scrollTop: 0 }, 'slow', function () {
alert("reached top");
});
});
Here is the fiddle for this
You can animate the scrollTop
property of the html, body
$('html, body').animate({
scrollTop: "0px"
}, 800);
I suggest you do some research/reading before you ask trivial questions like these. Google can help you out before all of us can.