How to know the item number and where it was moved from the element using Jquery UI?

Is the HTML code:
<tbody class="playlist">
the <tr>
<td class="droppable"><div class="draggable">Text</div></td>
<td>Button</td>
</tr>

the <tr>
<td class="droppable"><div class="draggable">Text2</div></td>
<td>Button2</td>
</tr>


Jquery UI is code for swap(swaps two elements) elements. Svataet only the first td text td second buttons remain in their seats.
<script type="text/javascript">
 $(document).ready(function () {
var dragLastPlace;
var movedLastPlace;


$('.draggable').draggable({
 placeholder: 'placeholder',
cursor:'move',
 zIndex: 1000,
 containment: 'tbody.playlist',
 helper: function(evt) {
 var that = $(this).clone().get(0);
$(this).hide();
 return that;
},
 start: function(evt, ui) {
 dragLastPlace = $(this).parent();
console.log($("tbody").index($('tr#2')));
},
 cursorAt: {
 top: 20,
 left: 20
}
});

$('.droppable').droppable({
 hoverClass: 'placeholder',
cursor:'move',
 drop: function(evt, ui) {
 var draggable = ui.draggable;
 var droppable = this;

 if ($(droppable).children('.draggable:visible:not(.ui-draggable-dragging)').length > 0) {
$(droppable).children('.draggable:visible:not(.ui-draggable-dragging)').detach().prependTo(dragLastPlace);
}

$(draggable).detach().css({
 top: 0,
 left: 0
}).prependTo($(droppable)).show();
 movedLastPlace = undefined;
},
 over: function(evt, ui) {
 var draggable = ui.draggable;
 var droppable = this;
 if (movedLastPlace) {
$(dragLastPlace).children().not(draggable).detach().prependTo(movedLastPlace);
}

 if ($(droppable).children('.draggable:visible:not(.ui-draggable-dragging)').length > 0) {
$(droppable).children('.draggable:visible').detach().prependTo(dragLastPlace);
 movedLastPlace = $(droppable);
}

}
});
});
</script>


Need to for example 1 element swapnote with 3 element later it will be using Ajax to go back.
How to obtain these items that cupolas?
March 23rd 20 at 19:34
1 answer
March 23rd 20 at 19:36
Solution
$(this).closest('tr').index()

In the handler, this will be the start index of the moved item into the drop, respectively - where they put.

Find more questions by tags jQueryJavaScript