I have made a nav bar that is originally white, but when the user scrolls down, it becomes transparent. When the nav bar is white at the top of the page, if the user hovers, it becomes transparent, and when his cursor leaves it returns to white. Now, logically, the same should happen when scrolled down, and it does. I don't want that to happen, instead I want the nav bar to stay transparent. So I've written the following code, but it is not working.
var color = $('.nav a').css("color")
if (color == rgb (0,0,249) ) {
$(".nav a").mouseenter(function(){
$(".nav a").stop( true ).animate({
backgroundColor: 'transparent',
});
$(".nav").stop( true ).animate({
backgroundColor: 'transparent',
});
});
$(".nav a").mouseleave(function () {
$(".nav a").stop( true ).delay(300).animate({
backgroundColor: 'white',
});
$(".nav").stop( true ).animate({
backgroundColor: 'white',
});
});
} else {
$(".nav a").mouseenter(function(){
$(".nav a").stop( true ).animate({
backgroundColor: 'transparent',
});
$(".nav").stop( true ).animate({
backgroundColor: 'transparent',
});
});
$(".nav a").mouseleave(function () {
$(".nav a").stop( true ).delay(300).animate({
backgroundColor: 'transparent',
});
$(".nav").stop( true ).animate({
backgroundColor: 'transparent',
});
});
}