0
如何在使用JQuery停止拖動時更改div的id。Draggable jquery
如何在使用JQuery停止拖動時更改div的id。Draggable jquery
$(「myDiv」)。attr('id','newid'); ??
可以使用stop
event,就像這樣:
$("#draggable").draggable({
stop: function() {
this.id = "newID"; //calc whatever the new ID is, assign here
}
});
You can test it here,在stop
回調,this
指拖動的元素,所以你想要什麼:)用它做
這是不工作在我的場景 – Xulfee 2010-07-16 12:08:57
xulfee - 也許尼克的工作(也,我的應該有讀:$('#myDiv')。attr('id','newid');我錯過了#符號,再試一次。 。 – 2010-07-16 12:11:29