set footer background after only scroll down event
Sets background image only when a user scrolls down (not to load every image at first)
document.addEventListener("scroll", setBG);
function setBG() {
    if (!bgSet) {
        var bgSet=1;
        id('table_footer').style.background='url(/images/footer.jpg?tg)';
        document.removeEventListener("scroll", setBG);
        console.log('fired');
    }
}
by Valeri Tandilashvili
4 years ago
JavaScript
4
Pro tip: use ```triple backticks around text``` to write in code fences