Advertisement
Guest User

Dynamic Go-to-Top Link using jQuery

a guest
May 26th, 2012
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.     jQuery(function () {
  3.         jQuery(document).ready(function () {
  4.             jQuery("#back-top").hide();
  5.             jQuery(function () {
  6.                 jQuery(window).scroll(function () {
  7.                     if (jQuery(this).scrollTop() > 100) {
  8.                         jQuery('#back-top').fadeIn('slow');
  9.                     } else {
  10.                         jQuery('#back-top').fadeOut('slow');
  11.                     }
  12.                 });
  13.                 jQuery('#back-top a').click(function () {
  14.                     jQuery('body,html').animate({
  15.                         scrollTop : 0
  16.                     }, 1300);
  17.                     return false;
  18.                 });
  19.             });
  20.         });
  21.     });
  22. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement