I want to hide the image when scroll
of the page is greater than 147, so that's fine, the problem is that I can not hide the image again when scroll
is less than 146. The goal is to hide and show the image according to the scroll.
Below is an example:
$(document).ready( () => {
var logo = $("#img-logo-fixed");
$(document).scroll( function() {
var scroll = $(document).scrollTop();
if(scroll >= 147) $("#img-logo-fixed").css("display", "block");
if(scroll < 146 ) $("img-logo-fixed").css("display", "none");
});
});
#img-logo-fixed {
position:fixed;
top:0;
display:none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><imgsrc="http://lucianodev.com/gameutil2d/site/imagens/icone-android.png" id="img-logo-fixed" >
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
Can anyone help me?