I'm having some problems with a .onscroll
function:
window.onscroll=function(){
if(document.documentElement.scrollTop>5){
menuPrincipal.style.backgroundColor = "rgba(0,0,0,1)";
}else{
menuPrincipal.style.backgroundColor = "rgba(0,0,0,.4)";
}
}
In this case, when I give scroll
to the page, it only reads the action of scroll
once, and always enters the condition else
, since scroll
starts at 0