[英]get list index id from div element
如何獲取每個列表索引的ID?
在螢火蟲中調試顯示:
<li class="droptrue ui-draggable" style="display: list-item;">
"...text of the li..."
</li>
我正在向每個列表元素傳遞一個唯一的ID。 這是jsfiddle中按比例縮小的示例:
http://jsfiddle.net/n2learning/tV4n7/89/
謝謝!
$('ul#routinefilter li').each(function () {
var id = $(this).attr('id');
});
為您的draggable
添加回調。
$(".droptrue").draggable({
snap: '#dropTargetframe',
connectToSortable: '#dropTargetframe',
helper: 'clone',
cursor: 'move',
revert: false,
drag: function (event, ui) {
var id = $(this).attr('id');
console.log(id);
}
});
id
屬性不會被克隆。 因此,將其更改為其他內容,例如data-id
可以解決您的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.