Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<link type="text/css" href="http://jqueryui.com/demos/sortable/../../themes/base/jquery.ui.all.css" rel="stylesheet" />
  <script type="text/javascript" src="http://jqueryui.com/demos/sortable/../../jquery-1.4.2.js"></script>
  <script type="text/javascript" src="http://jqueryui.com/demos/sortable/../../ui/jquery.ui.core.js"></script>
  <script type="text/javascript" src="http://jqueryui.com/demos/sortable/../../ui/jquery.ui.widget.js"></script>
  <script type="text/javascript" src="http://jqueryui.com/demos/sortable/../../ui/jquery.ui.mouse.js"></script>
  <script type="text/javascript" src="http://jqueryui.com/demos/sortable/../../ui/jquery.ui.sortable.js"></script>
  <link type="text/css" href="http://jqueryui.com/demos/sortable/../demos.css" rel="stylesheet" />
  <style type="text/css">
  #sortable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
  #sortable li { margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; font-size: 1.4em; height: 18px; }
  #sortable li span { position: absolute; margin-left: -1.3em; }
  </style>
</head>
<body>
  <div class="demo">
<ul id="sortable">
  <li class="ui-state-default fixed" id="f0"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Item 1</li>
  <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Item 2</li>
  <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Item 3</li>
  <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Item 4</li>
  <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Item 5</li>
  <li class="ui-state-default fixed" id="f5"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Item 6</li>
  <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Item 7</li>
</ul>
</div>
</body>
</html>
 
$(function() {
  $("#sortable").sortable({
    cancel: "li.fixed",
    stop:function(event, ui) {
      var f5 = $("#f5");
      var indf5 = $("#sortable li").index(f5);
      if(indf5 !== 5) {
        if(indf5 > 5) {
          f5.prev().insertAfter(f5);
        } else {
          f5.next().insertBefore(f5);
        }
      }
    }
  });
  $("#sortable").disableSelection();
});
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers