Skip to content

Instantly share code, notes, and snippets.

@mrkrand
Created April 5, 2016 15:04
Show Gist options
  • Save mrkrand/d5683480c36513aaf84a69470932ee73 to your computer and use it in GitHub Desktop.
Save mrkrand/d5683480c36513aaf84a69470932ee73 to your computer and use it in GitHub Desktop.
jQuery script thats toggles not-top class to body tag if user scrolls away
function pageNotTop() {
var notTop = false;
var body = jQuery('body');
jQuery(document).scroll(function() {
if (jQuery(document).scrollTop() > 0) {
if (!notTop) {
notTop = true;
body.addClass('not-top');
}
} else {
notTop = false;
body.removeClass('not-top');
}
});
}
pageNotTop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment