Advertisement
Guest User

Untitled

a guest
Dec 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.01 KB | None | 0 0
  1.        $('.menu-item a').click(function() {
  2.            
  3.             // console.log(this.hostname);
  4.             // console.log(location.hostname);
  5.             // console.log(location.origin);
  6.             // console.log(location.hash);
  7.            
  8.             if(this.hostname === location.hostname)
  9.             {
  10.                 console.log(this.pathname+this.hash);
  11.                 console.log(location.pathname);
  12.                
  13.                 if(location.pathname == "/" || location.pathname == "" || location.pathname == " " || location.pathname == this.pathname)
  14.                 {
  15.                   var target = $(this.hash);
  16.                   target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  17.                   if (target.length) {
  18.                      $('html, body').animate({
  19.                       scrollTop: target.offset().top
  20.                      }, 900);
  21.                     //  return false;
  22.                   }
  23.                 }
  24.                
  25.             }
  26.          });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement