Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. //Use smooth scrolling when clicking on navigation
  2. $('.navbar a').click(function() {
  3. if (location.pathname.replace(/^\//,'') ===
  4. this.pathname.replace(/^\//,'') &&
  5. location.hostname === this.hostname) {
  6. var target = $(this.hash);
  7. target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  8. if (target.length) {
  9. $('html,body').animate({
  10. scrollTop: target.offset().top-topoffset+2
  11. }, 500);
  12. return false;
  13. } //target.length
  14. } //click function
  15. }); //smooth scrolling
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement