当用户向下滚动超过页面的一半并在向上滚动时隐藏它时,是否有一种简单的方法可以在页面底部显示窗格。如果他们不想再次看到它,他们也应该能够关闭它。
这是我到目前为止所尝试的:
$(window).scroll(function() {
if($(this).scrollTop() > 200) {
$('#note').fadeIn();
} else {
$('#note').fadeOut();
}
});
$("#note").click(function() {
$("#note").fadeOut("slow");
return false;
});
答案 0 :(得分:0)
首先使用position:fixed
将您的小组置于底部:
#note{
display:none;
position:fixed;
bottom:0;
right:0;
}
然后点击后删除窗口的scroll
事件:
$("#note").click(function() {
$("#note").fadeOut("slow");
$(window).off('scroll');
});