Skip to content

Instantly share code, notes, and snippets.

@johhansantana
Last active May 15, 2017 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johhansantana/6d1f05d27aad0ceb092c to your computer and use it in GitHub Desktop.
Save johhansantana/6d1f05d27aad0ceb092c to your computer and use it in GitHub Desktop.
add navigation active as page scroll
$(function(){
$(window).scroll(function(){
var windscroll = $(window).scrollTop();
$('body .section').each(function(i){
if ($(this).position().top <= windscroll){
$('nav li.active').removeClass('active');
$('nav li').eq(i).addClass('active');
};
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment