拖和下降步驟我有這樣的代碼:JavaScript的:如何設置表
<div class="table-area">
<table>
<thead>
<tr>
<th>someDate</th>
<th>1</th>
<th>2</th>
<th>3</th>
</tr>
</thead>
<tbody>
<tr>
<td>someDateVal1</td>
<td class="data-cell"></td>
<td class="data-cell"></td>
<td class="data-cell"></td>
</tr>
<tr>
<td>someDateVal2</td>
<td class="data-cell"></td>
<td class="data-cell"></td>
<td class="data-cell"></td>
</tr>
</tbody>
</table>
<div class="table-area-selected"
draggable="true"></div>
</div>
和JS:
$(function() {
var selected = $('.table-area-selected');
var cell = $('table').find('.data-cell');
selected.css('width', $(cell[0]).outerWidth() * 2);
selected.css('height', $(cell[0]).outerHeight());
selected.css('top', $(cell[0]).position().top);
selected.css('left', $(cell[0]).position().left);
$('.table-area-selected').on('dragstart', function(event) {
console.log('drag', event);
});
$('table').on('drop', function(event) {
var selected = $('.table-area-selected');
var cell = event.target;
console.log('drop', event);
selected.css('width', $(cell).outerWidth() * 2);
selected.css('height', $(cell).outerHeight());
selected.css('top', $(cell).position().top);
selected.css('left', $(cell).position().left);
});
$('table').on('dragover', function(event) {
event.preventDefault();
});
});
https://plnkr.co/edit/NpRHbgHnUgGfgAOJnSTw?p=preview
是否有可能拖累這一項目像其他日程安排插件?像這樣:https://dhtmlx.com/docs/products/demoApps/room-reservation-html5-js-php/
因爲現在我的矩形是空閒的。我需要設置它在表網格的運動:像這樣: https://www.screencast.com/t/EXKQwTwTwkb ,而不是這樣的: https://www.screencast.com/t/g6jbP4s9hBX2
是否有可能呢?
我曾與HTML拖放開始嘗試這一點,但找不到任何辦法讓它做你想要的。 –