Please I would like to make a div disappear if it has been scrolled vertically up to 80% of it's total height. I tried using this javascript code but it didn't work.
<script>
window.onscroll = function() {myFunction()};
function myFunction() {
var scrollpercent = (document.body.scrollTop + document.documentElement.scrollTop)
/ (document.documentElement.scrollHeight - document.documentElement.clientHeight);
if ( scrollpercent>0.8{
document.getElementById("mega").style.display= "none";
}
else{
document.getElementById("mega").style.display= "block";
}
}
</script>
Please help me know what I am doing wrong.