Created
November 11, 2016 23:47
-
-
Save neilgee/75176a54faafd997ef0501686b9958b3 to your computer and use it in GitHub Desktop.
Add class to element when scrolling down page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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