How to change the menu background after scrolling the first screen?
CodePudding user response:
Try this
const menu = document.querySelector(".menu");
document.addEventListener("scroll", () => {
if (document.documentElement.scrollTop > window.innerHeigh)
menu.style.backgroundColor = "#ffffff";;
else
menu.style.backgroundColor = "#000000";;
});
CodePudding user response:
@Яцьків Юрий, does this help?
window.onscroll=function(ev)
{
if((window.innerHeight window.scrollY)>=document.body.offsetHeight)
{
document.getElementById('myawesomebackground').style.backgroundImage='myawesomeimage.png';
}
};