0
I would like to make a header that when scrolling down, it compresses its content. I have the following script so far.
window.scroll(function() {
var scroll = window.scrollTop();
var element = document.getElementById("nav");
if (scroll >= 140) {
element.classList.add("rola");
} else {
element.classList.remove("rola");;
}
});
I know the components HTML
are loaded after the object window
, then how would you proceed with the script? I don’t know how to wait for the component to load.
You can use
window.onscroll = function() { /* Code Here */ }
…– Valdeir Psr