How do I change the color of a menu when scrolling the page?
I'm doing this
$(function() {
$(window).on("scroll", function() {
if($(window).scrollTop() > 100) {
$(".sidebar-wrapper").addClass("teste2");
} else {
$(".sidebar-wrapper").removeClass("teste2");
}
});
});
And it's not working, can anyone help?
#sidebar-wrapper {
z-index: 1000;
position: fixed;
left: 250px;
width: 0;
height: 100%;
margin-left: -250px;
overflow-x: hidden;
background: #195884;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
.teste2{
background: #FFF;
}