Skip to content

Instantly share code, notes, and snippets.

@jonathan-bird
Created December 10, 2013 06:07
Show Gist options
  • Save jonathan-bird/7886342 to your computer and use it in GitHub Desktop.
Save jonathan-bird/7886342 to your computer and use it in GitHub Desktop.
Change div background at a certain scroll point
$(function() {
var fixadent = $(".logo-nav"); //the div you want
h = $(window).height(); //calculate height of window or whatever element you want it to scroll past
$(window).scroll(function() {
if($(this).scrollTop() > h ) {
$(fixadent).css('background', '#5fc1d8');
}
else {
$(fixadent).css('background', '#222');
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment