需要 jQuery 帮助



我正在将一个元素拖到另一个div上并将其放下。(克隆)我再次拖动相同的元素,因此可放置的div 上有 2 个相同的元素。

单击一个放置的对象,它会打开一个对话框,我填写该对话框,并且对象上的文本会发生变化。

正在发生的事情是两个删除的元素具有相同的文本。

我的问题是:

如何区分删除的元素,以便对一个元素的更改不会影响其他元素

我感谢任何人的投入。

这个怎么样:

完整的小提琴在这里:https://jsfiddle.net/red2678/4vLf1usz/27/

// Draggable
$("#draggable").draggable({
    revert: 'invalid',
    cursor: 'move',
    helper: 'clone'
});
// Droppable
$("#droppable").droppable({
    drop: function (event, ui) {
        // $this is the dropped elements container
        // $dd is the div where the dropped elements are
        // count is the count of currently dropped divs (1 based)
        // item is a clone of the draggable element
        // -- on item I am setting the id attribute
        // -- to be the word "drop" and the count
        // -- ex: drop1, then drop2 and so on.
        var $this = $(this),
            $dd = $this.find('#droppedDivs'),
            count = $dd.find('> div').length + 1 || 1,
            $item = $(ui.draggable).clone().attr('id', 'drop' + count);
        // Change the dropped elements container h3 to show
        // the dropped count and add hightlight class
        $this.addClass("ui-state-highlight")
            .find("h3")
            .html("Dropped " + count + "!");
        // Change content of dropped div to "id is #drop" and the count
        $item.html('id is #drop' + count);
        // Append to the dropped elements container
        $dd.append($item);
        // Now all divs inside #droppedDivs have unique ids :)
    }
});

最新更新