gpt4 book ai didi

Jquery droppable 获取可拖动 id

转载 作者:行者123 更新时间:2023-12-03 22:53:52 25 4
gpt4 key购买 nike

当我拖放到某个 div 时,我想获得拖动的 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) {

// i need to get dragged id (note:able to drag multiple ids)

1,2,3..

}
});

请帮帮我!!谢谢

最佳答案

正如他们在 jQuery UI 中所说的 dropable文档

All callbacks receive two arguments: The original browser event and a prepared ui object, view below for a documentation of this object (if you name your second argument 'ui'):

ui.draggable - current draggable element, a jQuery object.
ui.helper - current draggable helper, a jQuery object
ui.position - current position of the draggable helper { top: , left: }
ui.offset - current absolute position of the draggable helper { top: , left: }

ui.draggable 是作为 jQuery 对象 删除的元素。

所以你可以使用ui.draggable.prop('id')获取ID

关于Jquery droppable 获取可拖动 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10665901/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com