The following script is used in part 22 of the Image Gallery Tutorial at https://www.youtube.com/watch?v=agvNauJm3xI. This code can be copied and pasted into your document. For more information, go to https://jqueryui.com/sortable/#display-grid.
<!--sortableScript-->
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
$(function() {
$( "#record" ).sortable({cursor: "move"},{revert:true},{scroll:true},{scrollSensitivity: 10},{tolerance: "pointer"});
$( "#record" ).disableSelection();
$( "#record" ).sortable({
update: function( event, ui ) {
var listItems = $('#record div');
listItems.each(function(idx) {
$(this).find('.cos').val(idx+1);
});
}
});
});
</script>
<!--//sortableScript-->