Change BG of Header On Scroll

PHOTO EMBED

Sun Feb 11 2024 21:33:31 GMT+0000 (Coordinated Universal Time)

Saved by @Y@sir #change-background #scrolling #header

window.onscroll = function() {
2
    var header = document.getElementById('header-1');
3
    if (window.pageYOffset > 100) {
4
        header.style.backgroundColor = '#015478';
5
    } else {
6
        header.style.backgroundColor = 'transparent';
7
    }
8
}
9
content_copyCOPY

Set background color to the div on scrolling.