Click here to Skip to main content
15,903,824 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to add "Go to top Button " or scroll to top button into html 5 page?

i have a Angular js SPA with html 5 now i want to add scroll to top or go to top button into my Index.html page. how it is possible ???
Posted

Or the old-school way ^_^

https://jsfiddle.net/d7z32516/[^]

Bookmark links ftw :P
 
Share this answer
 
I did a small example in jsfiddle. Hope that helps you.

Click Here[^]

Button is just placed at the bottom irrespective of the page/document/content. Please make sure you have a floating button in the page as soon as the page starts scrolling a little.

You can use
JavaScript
$(document).on( 'scroll', function(){
   // Make the floating button visible with CSS 
});


On click of button, use the below code
JavaScript
$("#scrollUp").on('click', function(){
    $(window).scrollTop(0);
});


Happy coding!
RelicV
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900