Reputation: 13
I have this and guess that this list is a sortable one:
<ul>
<li id="a">Hey</li>
<li id="b">Ho</li>
<li id="c">Silver</li>
<li id="d">!</li>
</ul>
Now I'm sorting the list. I move the third <li id="c">Silver</li>
on before the first <li id="a">Hey</li>
what makes the list looks like this:
<ul>
<li id="c">Silver</li>
<li id="a">Hey</li>
<li id="b">Ho</li>
<li id="d">!</li>
</ul>
What I need to resolve now is the id of the DOM element ive sorted my list entry onto. In my example this should be "a" as it is the id of the first <li>
I've sorted my third <li>
onto.
Upvotes: 1
Views: 1011
Reputation: 42
You can get the id of the dragged and dropped element; use that to get the id of the next element on the same level:
$('#id_of_the_dragged_element').next().attr('id')
Upvotes: 1