jQuery – Back to top link


/ Published in: jQuery

Easy "back to top" scroll link


Copy this code and paste it in your HTML
  1. HTML:
  2.  
  3. <a href="#" class="backToTop">Back to top</a>
  4.  
  5.  
  6. jQuery:
  7.  
  8. $(document).ready(function(){
  9. $('a.backToTop').click(function(){
  10. $('html, body').animate({scrollTop: '0px'}, 300);
  11. event.preventDefault();
  12. });
  13.  
  14. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.