4

我正在尝试将图像放入 div 中,以在 id 为cesta的 div 中创建图像克隆,但我只得到禁止符号。

HTML

<div id='productos' >
   <h3>PRODUCTOS</h3>
   <img id='ali-12' name='serv' class='productos' src='img/objects_139.jpg' />
   <img id='mon-23' name='serv' class='productos' src='img/objects_132.jpg' />
   <img id='zap-32' name='serv' class='productos' src='img/objects_135.jpg' />
   <img id='gua-21' name='serv' class='productos' src='img/objects_102.jpg' />
   <img id='rod-11' name='serv' class='productos' src='img/objects_136.jpg' />
   <img id='maz-44' name='serv' class='productos' src='img/objects_137.jpg' />
   <img id='lla-97' name='serv' class='productos' src='img/objects_138.jpg' />
   <img id='par-10' name='serv' class='productos' src='img/objects_126.jpg' />
   <img id='cru-24' name='serv' class='productos' src='img/objects_121.jpg' />
   <img id='gaf-15' name='serv' class='productos' src='img/objects_131.jpg' />
</div>
<div id='cesta'>
</div>

JAVASCRIPT

$(document).ready(function(){
    $(".productos").draggable({helper:'clone'});  
    $("#cesta").droppable({
        accept: ".productos",
        drop: function(event,ui){
                $(this).append($(ui.draggable).clone());
        }
    });
});
4

1 回答 1

0

您的代码似乎工作正常。我试过了,效果很好。

除了您粘贴的内容之外,我所做的只是:

1) 添加了 2 个库

2)添加了一些CSS

JS代码和你的一样。

<script src="libs/jquery.js"></script>
<script src="libs/jquery_ui.js"></script>

<div id='productos' >
   <h3>PRODUCTOS</h3>
   <img id='ali-12' name='serv' class='productos' src='n-2.png' />
   <img id='mon-23' name='serv' class='productos' src='n-3.png' />
   <img id='zap-32' name='serv' class='productos' src='n-4.png' />
   <img id='gua-21' name='serv' class='productos' src='n-5.png' />
   <img id='rod-11' name='serv' class='productos' src='n-6.png' />
   <img id='maz-44' name='serv' class='productos' src='n-7.png' />
</div>
<div id='cesta'>
<script>
$(document).ready(function(){
$(".productos").draggable({helper:'clone'});  
$("#cesta").droppable({
    accept: ".productos",
    drop: function(event,ui){
            $(this).append($(ui.draggable).clone());
    }
  });
});
</script>

http://jsfiddle.net/janakshah89/sSRXk/1/

于 2013-05-08T10:42:01.243 回答