Last active
May 27, 2020 10:13
-
-
Save prosantamazumder/5e6fefbd15d97223b28c4aa7d3f34a54 to your computer and use it in GitHub Desktop.
smooth Scroll Section by ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function smoothScrollSectionID() { | |
$('.main-nav li > a').on('click', function (event) { | |
var target = $(this.getAttribute('href')); | |
if (target.length) { | |
event.preventDefault(); | |
$('html, body').stop().animate({ | |
scrollTop: target.offset().top - 80 | |
}, 1000); | |
} | |
}); | |
} | |
smoothScrollSectionID(); | |
//CLICK ADD CLASS | |
$(document).ready(function(){ | |
$('#primary-menu li').click(function(){ | |
$('#primary-menu li').removeClass("active"); | |
$(this).addClass("active"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment