Last active
September 11, 2016 05:35
-
-
Save sudarshanReddykurri/1076562c6d12e36fe512e7b3e7a21ff0 to your computer and use it in GitHub Desktop.
Code for on scroll background color change for the navigation in JQuery
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
<script> | |
$(document).ready(function(){ | |
$(window).scroll(function() { // check if scroll event happened | |
if ($(document).scrollTop() > 50) { // check if user scrolled more than 50 from top of the browser window | |
$('.header').css("background-color", "#fff");// change background-color to white | |
} else { | |
$('.header').css("background-color", "#000"); // if not, change it back to black | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment