Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  
  
<div id="items">
  <div class="item" style="height:48px;">Item description</div>
    <div class="item" style="height:98px;">Item description</div>
    <div class="item" style="height:198px;">Item description</div>
    <div class="item" style="height:88px;">Item description</div>
</div>
  
</body>
</html>
 
body{
background:#111;
}
.item{
  position:relative;
  border:1px solid#999;
  background:#444;
  width:300px;
  color:#fff;
}
 
$('.item').each(function(){
  
  if( $(this).next().is('.item') ){    
       var myHalf = $(this).outerHeight(true)/2;
       var nextHalf = $(this).next('.item').outerHeight(true)/2;
       $(this).text('distance in between: '+ (myHalf+nextHalf) );                  
  }
                  
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers