Skip to content

Instantly share code, notes, and snippets.

@zeshanshani
Created February 16, 2015 11:46
Show Gist options
  • Save zeshanshani/e268a505173162dc67b3 to your computer and use it in GitHub Desktop.
Save zeshanshani/e268a505173162dc67b3 to your computer and use it in GitHub Desktop.
Changing Navbar Background Color on Certain Scroll point
// Changing Navbar Background Color on Certain Scroll point
// By Zeshan Ahmed @zeshanshani
// After the addition, use class "alt-color" to style.
// .alt-color {
// background-color: #ff0000;
// }
jQuery(document).ready(function($) {
$(window).scroll(function() {
var scrollPos = $(window).scrollTop(),
navbar = $('.x-navbar');
if (scrollPos > 1000) {
navbar.addClass('alt-color');
} else {
navbar.removeClass('alt-color');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment