I have a top bar div under an element I am trying to show when page reload it has top:50px
and when user scroll page the position change to top:175px
as I have stick header too, but it is not working as expected.
it is behaving like this on page load -
and it has to look like this on page load -
window.onscroll = function () { scrollFunction() };
function scrollFunction() {
if (!document.body.scrollTop > 1 || document.documentElement.scrollTop > 1 ) {
document.getElementById("bar").style.top = "90px";
}else{
document.getElementById("bar").style.top = "175px";
}
}