This seems like it should be a simple task, but I'm a noob as far as goes jQuery, so here's what I'm looking for:
I have something like this:
<div class=draggable id=thing1> some contents </div>
<div class=draggable id=thing2> some other contents </div>
.
.
.
<div class=draggable id=thingN> content </div>
with this Javascript:
$(function() {
$(".draggable").draggable();
// from inside this block, how can I know the id of the thing I'm dragging?
}
开发者_开发百科
Use the stop
callback, and access the id
property of this
(a reference to the element being dropped).
$(".draggable").draggable({
stop: function() { alert(this.id); }
});
jsFiddle.
精彩评论