JQuery smooth scroll to anchor

From , 5 Years ago, written in JavaScript, viewed 81 times.
URL https://pastebin.vip/view/82aa4b0a
  1. // HTML:
  2. // <h1 id="anchor">Lorem Ipsum</h1>
  3. // <p><a href="#anchor" class="topLink">Back to Top</a></p>
  4.  
  5. $(document).ready(function (){
  6.     $("a.topLink").click(function (){
  7.         $("html, body").animate(
  8.         {
  9.             scrollTop : $($(this).attr("href")).offset().top + "px"
  10.         },
  11.         {
  12.             duration : 500,
  13.             easing : "swing"
  14.         });
  15.         return false;
  16.     });
  17. });
  18.  

Reply to "JQuery smooth scroll to anchor"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website