Window.onscroll = () => {
if (Window.innerHeight + Window.scrolly >= document.body.offsetHeight) {
document.querySelector('body').style.background = 'green';
} else {
document.querySelector('body').style.background = 'white';
}
}
I am new at coding, learning from an online course. Now I am stuck at it. i don't know what is wrong in here
As was mentioned in the comment you got wrong letter cases: window, scrollY
const body = document.querySelector('body');
body.style.height = '200vh'; // without content there's no scroll, so this will produce scroll;
window.onscroll = () => {
if (window.innerHeight + window.scrollY >= document.body.offsetHeight) {
body.style.background = 'green';
} else {
body.style.background = 'white';
}
}