I have a problem. I tried to do so that when I go down the navbar changes color it worked but the problem is that when I go up to the level of the slider it stays in the color that it changed. In this link you will find the whole code https://jsfiddle.net/khdtc6bn/ this is my js code
$(document).ready(function(){
$(window).scroll(function(){
var scroll = $(window).scrollTop();
if (scroll > 300) {
$(".navbar-custom").css("background" , "blue");
}
})
})
I would like that when I am all up it takes back this basic color, where is the problem in the code?
CodePudding user response:
You need to change the color again if the scroll is less or equal 300:
$(document).ready(function(){
$(window).scroll(function(){
var scroll = $(window).scrollTop();
if (scroll > 300) {
$(".navbar-custom").css("background" , "blue");
}
else{
$(".navbar-custom").css("background" , "rgba(255, 255, 255, 0.37)");
}
})
})