jQuery UI sortable: determining in what order the items are

后端 未结 5 925
深忆病人
深忆病人 2020-12-13 20:22

Here is an interesting use of JavaScript: reordering items with drag and drop. The implementation itself in my page works fine, but is there a way to determine in which orde

5条回答
  •  情话喂你
    2020-12-13 20:50

    This is what I use currently:

    $('#sortable').sortable({ update: function () { save_new_order() } }); function save_new_order() { var a = []; $('#sortable').children().each(function (i) { a.push($(this).attr('id') + ':' + i); }); var s = a.join(','); alert(s); }

    Alerted value:

    2000:0,1000:1,3000:2
    

提交回复
热议问题