Posted By

cerxx on 10/23/18


Tagged

jQuery-plugin


Versions (?)

How to make a smooth scrolling to a given place on the page using jQuery


 / Published in: JavaScript
 

URL: http://beloweb.ru/javascript-jquery/kak-sdelat-plavnuyu-prokrutku-k-zadannomu-mestu-na-stranitse-s-ispolzovaniem-jquery.html

If you click on the link, automatic scrolling is triggered, which moves us to the specified section.

  1. $('a[href^="#"]').bind('click.smoothscroll',function (e) {
  2. e.preventDefault();
  3.  
  4. var target = this.hash,
  5. $target = $(target);
  6.  
  7. $('html, body').stop().animate({
  8. 'scrollTop': $target.offset().top
  9. }, 500, 'swing', function () {
  10. window.location.hash = target;
  11. });
  12. });

Report this snippet  

You need to login to post a comment.