I'm trying to change the color of my navbar according to the page scroll, eg:
It starts as transparent, but when I scroll it turns white, if I scroll up again, it becomes transparent again, but it's not rolling, it turns white when I go down, but it does not come back transparent when I climb.
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";
}
});