views:

19

answers:

2

How can i change the id of div when drag is stop using JQuery.

+1  A: 

$("myDiv").attr('id', 'newid'); ??

jim
this is not working in my scenario
Xulfee
xulfee - perhaps nick's will work (also, mine should have read: $('#myDiv').attr('id', 'newid'); i'd missed out the # symbol. try it again..
jim
+1  A: 

You can use the stop event, like this:

$("#draggable").draggable({
   stop: function() {
     this.id = "newID"; //calc whatever the new ID is, assign here
   }
});

You can test it here, in the stop callback, this refers to the dragged element, so do with it what you want :)

Nick Craver