Skip to content

Instantly share code, notes, and snippets.

@neilgee
Created November 11, 2016 23:47
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 neilgee/75176a54faafd997ef0501686b9958b3 to your computer and use it in GitHub Desktop.
Save neilgee/75176a54faafd997ef0501686b9958b3 to your computer and use it in GitHub Desktop.
Add class to element when scrolling down page
jQuery(document).ready(function($){
// Add white class to site header after 50px
$(document).on( 'scroll', function() {
if ( $(document).scrollTop() > 50 ) {
$( '.site-container' ).addClass( 'white' );
} else {
$( '.site-container' ).removeClass( 'white' );
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment