I have a id="header"
div that initially has css rule: padding: 25px 0;
. I want to decrease the padding of this div when scrolling down the page.
$(document).ready(function() {
var headerID = $("#header");
$(this).scroll(function() {
if (!$(this).scrollTop())
headerID.toggleClass("headerScrolled");
else if (!headerID.is(".headerScrolled"))
headerID.toggleClass("headerScrolled");
});
});
.headerScrolled {
padding: 15px 0;
}
Despite implementing this code, I am not seeing any changes in padding while scrolling down. What could be possibly wrong with my code?