Advertisement
IlyaOlchikov

menu scroll

May 20th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function menuScroll(href) {
  2.     var hrefArr = href.split('#');
  3.     if (hrefArr.length == 2) {
  4.       if ($('#' + hrefArr[1]).offset()) {
  5.         $("body, html").animate({
  6.           scrollTop : $('#' + hrefArr[1]).offset().top - 150
  7.         }, 800);
  8.         return false;
  9.       }
  10.     }
  11.     return true;
  12.   }
  13.  
  14.   menuScroll(window.location.href);
  15.  
  16.   $('.nav li a').click(function() {
  17.     return menuScroll($(this).attr('href'));
  18.   })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement