3

我想将一些图像从 div 拖到另一个 div...我有一个 div 容器,它还有 5 个 div,在这 5 个 div 中有一些 png。我需要的是将这些 png 从第一个 div 一个一个拖到一个 id="dropspot" 的 div,然后单击“下一步按钮”以更改为容器中的第二个 div 并清除 droppot div,依此类推,直到第 5 分区

我尝试了一些东西,但不是我需要的:(这些功能使所有图像都可拖动,我只需要容器内的图像即可拖动。

这是一个小提琴:http: //jsfiddle.net/ygaw2/7/

和一些代码:

$(function() {
    $( "#container img" ).draggable();
    ({
    containment: "#container",    
    revert: "invalid",
    helper: "clone"

    });
    $( "#dropspot" ).droppable({

      tolerance: 'fit',

      drop: function( event, ui ) {


      }
    });
  });
4

1 回答 1

2

Try this solution: http://jqueryui.com/droppable/#photo-manager It seems to me just like u wanna it to work.

In droppable callback u can clear droppable element content.

EDIT

Everything you need is in that example ive linked + one thing:

$( "#container img" ).draggable({
    containment: "#container",    
    revert: "invalid",
    helper: "clone"

    });

Delete (); after draggable

于 2014-01-15T10:02:53.410 回答