Advertisement
Guest User

Untitled

a guest
Jan 14th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function( $ ) {
  2.  
  3.     $('a[href*=#]:not([href=#])').click(function() {
  4.  
  5.         if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
  6.            
  7.             var target = $(this.hash);
  8.             var target_id = target.attr('id');
  9.             target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  10.             if (target.length) {
  11.                 $('#navigation .current-menu-item').removeClass('current-menu-item');
  12.                 $('#navigation a[href="#' + target_id + '"]').closest('li').addClass('current-menu-item');
  13.                 $('html,body').animate({
  14.                     scrollTop: target.offset().top - $('#header').outerHeight()
  15.                 }, 1000);
  16.                 return false;
  17.             }
  18.  
  19.         }
  20.  
  21.     });
  22.  
  23. })( jQuery );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement