I am trying to make a div
visibe only after a certain scroll length.
There are already some threads here on Stackoverflow about it and so I have tried to use the suggested scripts listed in the answers, but no one of them seems to work.
So, I suppose that I don't know how to use them.
I have put this block into the head
, surrounded by the two script
tags:
function scroll_bar() {
if (document.body.scrollTop > 700) {
document.getElementById("navigation_bar").show();
}
else
{
document.getElementById("navigation_bar").hide();
}
}
And in the body
, I have a div
(the one that I want to make visible/hidden) with these attributes:
<div onload="scroll_bar();" class="container" id="navigation_bar" style="position: fixed; z-index: 1; background-color: white; height: 50px; width: 100%;"></div>
What is wrong over here? (I am using Bootstrap anyway, that "container" class comes from it.)