Advertisement
Guest User

Untitled

a guest
May 20th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. ( function( $ ) {
  2. $(document).on('click', 'a[href*="#"]:not([href="#"])', function(e) {
  3. if (location.pathname.replace(/^\//,'') === this.pathname.replace(/^\//,'') && location.hostname === this.hostname) {
  4. var hashStr = this.hash.slice(1);
  5. var target = $(this.hash);
  6. target = target.length ? target : $('[name=' + hashStr +']');
  7. if (target.length) {
  8. $('html, body').animate({ scrollTop: target.offset().top }, 1000);
  9. window.location.hash = hashStr;
  10. return false;
  11. e.preventDefault();
  12. }
  13. }
  14. });
  15. }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement