[英]Get the elements id already in the droppable div
我知道有很多與此相關的問題,但是由於我是jQuery html的新手,所以無法弄清楚該怎么做。
我有一個div容器(其中已經有一些elements(div)),並且要在其中放其他div。
我想知道的是刪除時容器中已經存在的所有divs ID。
我要添加的是從組到容器的相同類型的項目,現在,如果我兩次添加相同的項目,我需要知道容器中已經存在多少相同類型的項目,因此我可以創建其ID為car1,ca2,car3等
我知道這有點令人困惑,如果可以讓您理解,請隨意說。
謝謝。
我知道有很多與此相關的問題,但是由於我是jQuery html的新手,所以無法弄清楚該怎么做。
我有一個div容器(其中已經有一些elements(div)),並且要在其中放其他div。
我想知道的是刪除時容器中已經存在的所有divs ID。
我要添加的是從組到容器的相同類型的項目,現在,如果我兩次添加相同的項目,我需要知道容器中已經存在多少相同類型的項目,因此我可以創建其ID為car1,ca2,car3等
我知道這有點令人困惑,如果可以讓您理解,請隨意說。
謝謝。
$( "#c1 .component-group" )
.droppable({ activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
accept: ":not(.ui-sortable-helper)",
drop: function( event, ui ) {
var draggedImage = ui.draggable.find("img").attr("src");
var draggableAdded;
for (i =0 to elements in c1 )
{
if(element dragged == element present )
get the id
new_id = id + 1
make a new div with new_id and append with the container.
}
$(event.target).append(draggableAdded);
}
});
如果我了解您的要求,就可以解決這個問題:
ui.draggable.("#c1 .component-group").serialize()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.