0
私はjQueryソート可能です。私は移動したアイテムのIDとそれが置き換えたアイテムのIDを取得できるようにしたい。これまでは、移動した要素のIDは取得できましたが、置き換えられた要素は取得できませんでした。jqueryで移動したIDと置き換えられたIDを取得する方法
私のコードは次のとおりです。
$(function() {
$("#sortable").sortable({
stop: function (event, ui) {
var moved = ui.item,
replaced = ui.item.prev();
// if replaced.length === 0 then the item has been pushed to the top of the list
// in this case we need the .next() sibling
if (replaced.length == 0) {
replaced = ui.item.next();
}
alert("moved ID:" + moved.attr("id"), "replaced ID:" + replaced.attr("id"));
}
});
});
どのように私は戻って交換される要素のためのIDと移動された要素の両方を得るのですか?
うわー、おかげでたくさんのダリオ。 – kevinabraham