我为不同的答案制作了这个 jsfiddle,我想知道如何获得可放置的源容器
jQuery是
$("#Table1 tr:not(.disabled), #Table2 tr:not(.disabled), #Table3 tr:not(.disabled)").draggable({
helper: 'clone',
revert: 'invalid',
start: function (event, ui) {
$(this).css('opacity', '.5');
},
stop: function (event, ui) {
$(this).css('opacity', '1');
}
});
$("#Table1, #Table2, #Table3").droppable({
drop: function (event, ui) {
$(ui.draggable).appendTo(this);
alert($(ui.draggable).text() +
' was draged from ' +
'XX' + ' to ' +
$(this).attr('id') + '.');
}
});
和 html 是
<h1>Table 1</h1>
<table id="Table1">
<tr><td>Row 3</td></tr>
<tr class='disabled'><td>Row 4</td></tr>
<tr><td>Row 5</td></tr>
</table>
<h2>Table 2</h2>
<table id="Table2">
<tr><td>Row 8</td></tr>
<tr class='disabled'><td>Row 9</td></tr>
<tr><td>Row 10</td></tr>
</table>
<h2>Table 3</h2>
<table id="Table3">
<tr><td>Row 11</td></tr>
<tr><td>Row 12</td></tr>
</table>