I have the following HTML
HTML
<ul id="sortable" class="ui-sortable">
<li id="369833" class="ui-state-default">
<li id="372915" class="ui-state-default">
<li id="276520" class="ui-state-default" style="">
<li id="373229" class="ui-state-default">
<li id="373231" class="ui-state-default">
<li id="373253" class="ui-state-default">
</ul>
I can sort my <li> elements but I need know the position of a specific <li> that I sort.
Exemple
If I put in my console $("#sortable").find("li").size(), I have the return of the numbers of <li> are in my <ul>, 6 in this case. But how can I know the position of a specific <li> like, the <li> with the id 373231, where this <li> are inside my <ul> ? The return that I want is the number 5, because he is the fifth <li> element in my <ul>
UPdate
My function
$(function () {
$("#sortable").sortable({
stop: function (event, ui) {
debugger;
// Getting a WRONG Position
alert($(this).index());
}
});
$("#sortable").on("sortstop", function (event, ui) {
// Getting a WRONG Position
alert($(this).index());
});
$("#sortable").disableSelection();
});
jquery index() is what you need here..
In your case
EDITED
take the index of the
ui.itemhers is the fiddle