Skip to content

Instantly share code, notes, and snippets.

@prosantamazumder
Last active May 27, 2020 10:13
Show Gist options
  • Save prosantamazumder/5e6fefbd15d97223b28c4aa7d3f34a54 to your computer and use it in GitHub Desktop.
Save prosantamazumder/5e6fefbd15d97223b28c4aa7d3f34a54 to your computer and use it in GitHub Desktop.
smooth Scroll Section by ID
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