小编Suj*_*ith的帖子

如何获取已删除元素的 id - jquery UI

我尝试了很多方法来获取 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)

javascript jquery jquery-ui

2
推荐指数
1
解决办法
4448
查看次数

标签 统计

javascript ×1

jquery ×1

jquery-ui ×1