[英]Hide at 80% height after show/hide DIV when passed another DIV
I try to hide a DIV at 80% height that shows/hide when another DIV passed before. 我尝试隐藏80%高度的DIV,该高度在之前通过另一个DIV时显示/隐藏。
This is the code (Source) to show/hide after passed the DIV: 这是通过DIV后显示/隐藏的代码(源) :
<script type="text/javascript">
$(function(){
$(document).scroll(function(){
var vis = ($(document).scrollTop() > ($('.passedMe').offset().top+$('.passedMe').height()));
if (vis) $('.showHide').fadeIn(); else $('.showHide').fadeOut();
});
});
</script>
The DIV should hide at 80% height of the page. DIV应该隐藏在页面高度的80%处。
Like this (Source) : 像这样(来源) :
<script>
var y = $(this).scrollTop();
if (y < ($(document).height() * 0.8)) {
$('.showHide').fadeIn();
} else {
$('.showHide').fadeOut();
}
</script>
I get it! 我知道了!
Here is the working code: 这是工作代码:
<script type="text/javascript">
$(function(){
$(document).scroll(function(){
var y = $(this).scrollTop();
var vis = $(document).scrollTop();
if (vis > ($('.passedMe').offset().top+$('.passedMe').height()) && y < ($(document).height() * 0.8)) {
$('.showHide').fadeIn();
} else {
$('.showHide').fadeOut();
}
});
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.