Count divs in outside window height position

do you know if there is a way in jquery/javascript to count the divs outside window screen height?

like the image, in the green area ?

在这里输入图像描述

Thank you in advance


我已经创建了示例片段作为参考如何检查Mojo在评论中是否提供了屏幕外的元素

jQuery.expr.filters.offscreen = function(el) {
  var rect = el.getBoundingClientRect();
  return (
           (rect.x + rect.width) < 0 
             || (rect.y + rect.height) < 0
             || (rect.x > window.innerWidth || rect.y > window.innerHeight)
         );
};


function checkOutsideDiv(){
	var allEl = $('.common-class');
  allEl.each(function(i, el){
  	console.log($(el).is(':offscreen'));
  });
}
.wrap{
  padding:20px;
  border:dotted 2px red;
  width:100%;
  float:left;
}

.common-class{
  width:40%;
  height:200px;
  line-height:200px;
  border:1px dashed green;
  float:left;
  margin:5px;
  text-align:center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<button type="button" onclick="checkOutsideDiv()">
Check
</button>

<div class="wrap">
  <div class="common-class"> 1  </div>
  <div class="common-class"> 2  </div>
  <div class="common-class"> 2  </div>
  <div class="common-class"> 4  </div>
  <div class="common-class"> 5  </div>
  <div class="common-class"> 6  </div>
  <div class="common-class"> 7  </div>
  <div class="common-class"> 8  </div>
  <div class="common-class"> 9  </div>
  <div class="common-class"> 10  </div>
  <div class="common-class"> 11  </div>
  <div class="common-class"> 12  </div>
  <div class="common-class"> 13  </div>
  <div class="common-class"> 14  </div>
  <div class="common-class"> 15  </div>
</div>
链接地址: http://www.djcxy.com/p/14640.html

上一篇: jQuery hasAttr检查一个元素是否有属性

下一篇: 在外窗高度位置计数div