SortableJS

v1.15.7

Drag and drop reordering for lists and grids, including touch devices.

Quick start

Add this tag to your page. Place it just before the closing </body> tag, or in the <head> with the defer attribute.

HTML
<script src="https://jscdns.net/libs/sortablejs/1.15.7/Sortable.min.js"
        integrity="sha384-DgmC6Xe2bSN2WjTDXzWYbUbxyhNP+NNkGDR/g78pCXV7E7rcVTGxVg0uIVCUUcBc" crossorigin="anonymous"></script>

Files

FileSizeCopy
Sortable.min.jsScript 44.4 KB

Usage

Complete example

A minimal page that loads SortableJS and uses it. Copy it into a file and open it in your browser.

example.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
</head>
<body>
  <ul id="tasks">
    <li>Write report</li>
    <li>Review findings</li>
    <li>Send to client</li>
  </ul>

  <script src="https://jscdns.net/libs/sortablejs/1.15.7/Sortable.min.js"
          integrity="sha384-DgmC6Xe2bSN2WjTDXzWYbUbxyhNP+NNkGDR/g78pCXV7E7rcVTGxVg0uIVCUUcBc" crossorigin="anonymous"></script>
  <script>
    Sortable.create(document.querySelector('#tasks'), {
      animation: 150,
      onEnd: function (event) {
        console.log('Moved from', event.oldIndex, 'to', event.newIndex);
      }
    });
  </script>
</body>
</html>
Good to know. Works with plain lists and grids and needs no other dependencies.