<ul id="RSS_sortable"> <?php for($i=1;$i<=5;$i++){ ?> <li class="ui-state-default drag" id="<?php echo $i; ?>" style="margin:10px; padding:10px"> <!-- RSS --> email: <input name="email to us: " type="text" value="email to us" size="20" > email address: <input name="email_address" type="text" value="support@looptek.com" size="20"> <span class="ui-icon ui-icon-trash" style="float:right" >Delete </span> </li> <?php } ?> </ul> <script type="text/javascript"> $( "#RSS_sortable" ).sortable({ revert: true, axis:'y', update:function(event, ui){ var t1 = $(this).sortable('toArray').toString(); // pos = $(ui.item).attr("id"); // alert(pos); // alert($(ui.item).text()); // t1=$('ul.li:nth-child(0)').attr("id"); alert(t1); } }); $( "#draggable" ).draggable({ connectToSortable: "#RSS_sortable", helper: "clone", revert: "invalid" }); $( "ul, li" ).disableSelection(); </script>