I adding new form elements into a sortable list. When the list is rearranged, I'd the like ID's to be consecutive. Code so far:
$( "#sortable" ).sortable();
$( "#sortable" ).disableSelection();
var counter = 1;
$('a').click(function () {
var elems = '<li>'
'<input name="q_' + counter + '" type="text"/>' +
'<select name="type_' + counter + '" >
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>' +
'</li>' ;
$('#sortable').append(elems);
counter++;
return false;
});
This produces a list with consecutive IDs, which go out of sync when rearranged. How can I use jquery to iterate through the list and reassign element IDs?