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 class="box">test</div>
  <div class="box">test</div>
  <div class="box">test</div>
  <div class="box">test</div>
  
  
</body>
</html>
 
*{margin:0;padding:0;}
.box{
  background:#333;
  width:100px;
  height:100px;
  position:relative;
  float:left;
  color:#666;
}
.left{
  background:#cf5;
}
 
function checkPositions(){    
    $('.box').each(function(){
       var myPos = $(this).position().left === 0 ?
       $(this).removeClass('right').addClass('left') :           
       $(this).removeClass('left').addClass('right') ;
    });  
}
checkPositions();
$(window).resize(function(){
    checkPositions();
});
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers