Hello guys, I have a problem connected with jquery. When a user reaches 500px a picture with id pic-container appears. Below is the code
$(document).scroll(function () {
var y = $(this).scrollTop();
if (y > 500) {
$('#pic-container').fadeIn();
} else {
$('#pic-container').fadeOut();
}
});
Now the thing is that when a user go back to top, the picture hides and when coming down to 500px that picture appears again. But I want the picture fade in just one time and not to be hidden when user scrolls up.
Thanks in advance