jQuery代码
function itemInSpot(drag_item,spot)
{
var oldSpotItem = $(spot).find('img');
if(oldSpotItem.length>100) {
oldSpotItem.appendTo('#itembox4').draggable({ revert: 'invalid' });
}
var item = $('<img />');
item.attr('src',drag_item.attr('src')).attr('class',drag_item.attr('class')).appendTo(spot).draggable({ revert: 'invalid' });
drag_item.remove(); // remove the old object
}
$(document).ready(function() {
$("img").draggable({ revert: 'invalid'});
$("img").addClass(classname,function(index,currentclass))
$("#itembox4").droppable()
$("#pricebox").droppable({ accept: '#price'});
$('#pricebox').droppable({ accept: '#price'});
$('#pricebox,#pricebox,#itembox4').bind('drop', function(ev,ui) { itemInSpot(ui.draggable,this); });
$('#itembox4 img').hide();
$('#clone_button').click(function() {
$('#clone_wrapper div:#pricebox')
.clone()
.append('')
.appendTo($('#clone_wrapper'));
})
});
$(function() {
$('#filter').change(function(){
$('#itembox4 img').hide();
$('.'+$(this).val()).show();});
});
我已经添加了,$("img").addClass(classname,function(index,currentclass))
但是一旦我移动我的图像,它就会丢失它的id,当我将它拖回它的盒子时,它不会让我重新拖出它。
我想达到什么目的?
可移动的图像要么不会丢失其id ,要么在拖放后自动重新添加。
图像都死了,但它们仍然可以与 jquery 一起使用。
我尝试过
将项目改回class="price"
而不是id="price"