我尝试了很多方法来获取 jquery UI 中删除元素的 id。请帮忙获取id的值。
$( function() {
$(".draggable").draggable({
revert: "invalid",
helper: "clone"
});
$( "#droppable2" ).droppable({
drop: function( event, ui ) {
var draggable = ui.draggable;
var dragged = draggable.clone();
var currentID = ui.draggable.attr("id");/*draggable.find('id'); - returns an object. but, could not get the id. */
alert(dragged.html());
alert(currentID);
dragged.resizable();
dragged.appendTo("#droppable2");
//alert("open properties");
}
});
} );
Run Code Online (Sandbox Code Playgroud)
删除元素的 html 返回并包含 id。
---html---
<div class="ui-widget-content draggable">
<select id='singleSelect'>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
</div>
<div id='droppable2' class="ui-widget-header" height='100%'><p/></div>
Run Code Online (Sandbox Code Playgroud)