Advertisement
fauzanjeg

Add Scroll to Top button in Mobile Device

May 18th, 2021
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function ($) {
  2.     var scrollto = $('.jscroll-to-top');
  3.  
  4.     var do_scroll_to_top = function () {
  5.         var st = $(window).scrollTop();
  6.  
  7.         if (st > 400) {
  8.             scrollto.addClass('show');
  9.         } else {
  10.             scrollto.removeClass('show');
  11.         }
  12.     }
  13.  
  14.     scrollto.on('click', function () {
  15.         $('html, body').animate({ scrollTop: 0 }, 600);
  16.         return false;
  17.     });
  18.  
  19.     $(window).on('scroll load', do_scroll_to_top);
  20. })(jQuery)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement