Get ID of dragged list item in a sortable jQuery

jquery, jquery-ui-sortable, list

Solution

Inside the `update` event callback you can do this (demo):

$( "#listofpages" ).sortable({
  update: function( event, ui ) {
    var id = ui.item.attr("id");
  }
});

Problem

I have this html: ``` <ul> <li id='item1'>First</li> <li id='item2'>Second</li> <li id='item3'>Third</li> </ul> ``` and this .sortable jQuery: ``` $(function(){ $("#listofpages").sortable({ } }) ``` How can I get the id of the dragged element?

Original source

Related problems