0
jQuery的如何在一個表中拖動列
$('a').draggable({
containment: "table",
revert: 'invalid'
});
var i = 0;
$('td').droppable({
drop: function (ev, ui) {
var dropped = ui.draggable;
var droppedOn = $(this);
$(droppedOn).droppable("disable");
$(dropped).parent().droppable("enable");
$(dropped).detach().css({
top: 0,
left: 0
}).appendTo(droppedOn);
}
});
$('td').not('td:empty').droppable("disable");
$('#red').droppable({
drop: function(ev, ui) {
dropped = ui.draggable;
droppedOn = $(this);
if ($(droppedOn).droppable()){
i++;
}else{
i--;
}
if (i==3){
$(droppedOn).droppable("disable");
$(dropped).parent().droppable("enable");
$(dropped).detach().css({top: 0, left: 0}).appendTo(droppedOn);
}else{
$(droppedOn).droppable("enable");
}
},
out: function(event, ui) {
i=i-1;
}
});
小提琴:https://jsfiddle.net/uo8x5ks2/
我試圖讓紅色背景,當我將它拖到一起以T移動。 現在只能讓我拖動T 謝謝你的時間