I want to get multiple dragged ids when i dropped to the certain div.
$(ui.draggable).attr('id'); only gets 1st id.
Not working:
var m_ids = [];
$.each($(ui.draggable), function(i,e) {
m_ids.push(e.id); // not getting multiple ids
alert(m_ids);
});
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
var m_ids = [];
$.each($(ui.draggable), function(i,e) {
m_ids.push(e.id); // not getting multiple ids
alert(m_ids);
});
}
});
Please help me out.
Did you try:
If there’s only one element,
$(ui.draggable)probably only contains one element, and the other elements could be children, check the console withconsole.log($(ui.draggable)).