Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>Test Page</title>
<style>
  body {
    font-family: sans-serif;
  }
  #container div {
    float: left;
    width: 4em;
    border: 1px solid black;
    margin: 2px;
    padding: 2px;
  }
  .left, .right {
    cursor: pointer;
    font-weight: bold;
    font-size: 14pt;
    background-color: #eee;
    border: 1px solid #aaa;
  }
</style>
</head>
<body>
  <div id="container">
    <div class="fasy">d1 <span class='left'>&lt;</span></div>    
    <div>d2 <span class='left'>&lt;</span> </div>
    
    <div>d3 <span class='left'>&lt;</span> </div>
    
    <div>d4 <span class='left'>&lt;</span> </div>
    
  </div>
</body>
</html>
 
$(function() {
  
  var container = $("#container");
  var index;
  
  
  
  $("#container").delegate(".left", "click", function() {
    var div = $(this).prev("div.fasy"),
        prev = div.prev();
    if (prev[0]) {
      div.insertBefore(prev);
    }
  });
});
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers