Skip to content

Instantly share code, notes, and snippets.

@Niloys7
Created November 15, 2015 03:33
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 Niloys7/fe3512da915368d919f3 to your computer and use it in GitHub Desktop.
Save Niloys7/fe3512da915368d919f3 to your computer and use it in GitHub Desktop.
Trigger action when a user scrolls past a certain part of the page
$(window).scroll(function() {
var y_scroll_pos = window.pageYOffset;
var scroll_pos_test = 500;
// set to whatever you want it to be
if(y_scroll_pos > scroll_pos_test) {
$("body").css("background-color","#000");
}
else
{
$("body").css("background-color","#FFF");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment