2
I’m trying to change the color of my navbar according to the page scroll, ex:
It starts as transparent, but when I give it a scroll it turns white, if I scroll up again, it turns transparent, only it’s not rolling, it turns white when I go down, but it doesn’t go back to transparent when I go up.
What am I doing wrong?
document.addEventListener("scroll", function() {
var posicaoy = document.scrollTop;
if (posicaoy == 0) {
navbar.style.backgroundColor = "trasnparent";
} else {
navbar.style.backgroundColor = "white";
}
});