I want to have a navbar that automatically shows up when you are not on the top of the page, that is working; the thing is when I scroll back to the top nothing changes. Could somebody look at my code and tell me what I need to change or update?
$(document).ready(function() {
$(window).scroll(function() {
console.log($(window).scrollTop());
if ($(window).scrollTop() != 0) {
$("#topnav").animate({
opacity: 1
}, 300);
} else if ($(window).scrollTop() == 0) {
console.log("done");
$("#topnav").css({
opacity: 0
});
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
The console
does give me a return, yet the page does not seem to change..