2010-07-16 88 views

回答

1

$(「myDiv」)。attr('id','newid'); ??

+0

這是不工作在我的場景 – Xulfee 2010-07-16 12:08:57

+0

xulfee - 也許尼克的工作(也,我的應該有讀:$('#myDiv')。attr('id','newid');我錯過了#符號,再試一次。 。 – 2010-07-16 12:11:29

2

可以使用stop event,就像這樣:

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

You can test it here,在stop回調,this指拖動的元素,所以你想要什麼:)用它做