Allows the dragging and sorting of lists.

Example

Sort the buttons

<ol id="sortExample">
    <li><a class="btn btn-sm btn-default">First</a></li>
    <li><a class="btn btn-sm btn-primary">Second</a></li>
    <li><a class="btn btn-sm btn-success">Third</a></li>
</ol>

<script>
    $('#sortExample').sortable()
</script>

<style>
    body.dragging, body.dragging * {
        cursor: move !important
    }
    .dragged {
        position: absolute; opacity: 0.5; z-index: 2000;
    }
    #sortExample li.placeholder {
        position: relative;
    }
</style>

JavaScript API

The sortable() method must be invoked on valid containers, meaning they must match the containerSelector option.

.sortable('enable') Enable all instantiated sortables in the set of matched elements

.sortable('disable') Disable all instantiated sortables in the set of matched elements

.sortable('refresh') Reset all cached element dimensions

.sortable('destroy') Remove the sortable plugin from the set of matched elements

.sortable('serialize') Serialize all selected containers. Returns a jQuery object . Use .get() to retrieve the array, if needed.

Supported options

Supported options (container specific)