当我跌入某个div时,我希望获得多个拖动的ID。 $(ui.draggable).attr('id');
只获得第一个ID。
Drag <ul id="demo" >
<li id="1" ></li>
<li id="2" ></li>
<li id="3" ></li>
</ul>
<div class="drop"> drop here!! </div>
JQUERY
$(".drop").droppable({
drop: function(event, ui) {
var m_id = $(ui.draggable).attr('id');// only gets 1st id
// i need to get multiple dragged id
1,2,3..
}
});
请帮帮我!! Thnks
答案 0 :(得分:3)
var m_id = [];
$.each($(ui.draggable), function(i,e) {
m_id.push(e.id);
});
//gives array with all ID's, could be joined with join()
//for comma seperated list
答案 1 :(得分:0)
$("li").draggable({ revert: true });
$(".drop").droppable({
drop: function(event, ui) {
var id = ui.draggable.attr("id");
alert(id);
}
});