Skip to content

Instantly share code, notes, and snippets.

@dompascal
Created November 23, 2013 11:01
Show Gist options
  • Save dompascal/7613263 to your computer and use it in GitHub Desktop.
Save dompascal/7613263 to your computer and use it in GitHub Desktop.
JS - Fixed Class on Scroll
// fixed nav on scroll
$(window).scroll(function(e) {
if ($(this).scrollTop() > 240 && !$('body').hasClass('fixed')) {
$('body').addClass('fixed');
}
else if ($(this).scrollTop() <= 240 && $ ('body').hasClass('fixed')) {
$('body').removeClass('fixed');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment