Home > Blockchain >  Сhange menu after scrolling the first screen
Сhange menu after scrolling the first screen

Time:11-18

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';
 }
};
  • Related