My navbar has a transparent background, and I wanted to add a different bg when a user scrolls down.
I used the code from this question: Changing nav-bar color after scrolling?
my code now looks like this:
$(document).ready(function(){
var scroll_start = 0;
var startchange = $('#startchange');
var offset = startchange.offset();
if (startchange.length){
$(document).scroll(function() {
scroll_start = $(this).scrollTop();
if(scroll_start > offset.top) {
$(".navbar-fixed-top").css({'background-color':'#24363d',
'opacity': '0.3'});
} else {
$('.navbar-fixed-top').css({'background-color':'transparent'});
}
});
}
});
When I scroll down, everything works ok, the bg and the opacity applies, but when I scroll back to the top this style is still there. I want it to change back to the default styling with no background.
Thanks