SHARE
TWEET

Back To Top Button JS & HTML

makemyblogbetter Jun 17th, 2019 (edited) 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.     window.onload=function(){
  3. jQuery(document).ready(function($) {
  4.   var visible = false;  
  5.   $(window).scroll(function() {
  6.     var scrollTop = $(this).scrollTop();
  7.     if (!visible && scrollTop > 100) {
  8.       $(".scrollToTop").fadeIn();
  9.       visible = true;
  10.     } else if (visible && scrollTop <= 100) {
  11.       $(".scrollToTop").fadeOut();
  12.       visible = false;
  13.     }
  14.   });
  15.   $(".scrollToTop").click(function() {
  16.     $("html, body").animate({
  17.       scrollTop: 0
  18.     }, 800);
  19.     return false;
  20.   });
  21. });
  22.     }
  23. </script>
  24.  <a href="#" class="scrollToTop" style="display: none;"><img src="IMAGE URL HERE"></a>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top