0
下面是我的示例截圖。拖拽使用jquery填充空格
我曾與拖嘗試和下降。在前2個截圖中會有拖放。它的工作正常。初始時會出現空框。但是,如果我在拖動框中設置了一些默認值,它將摺疊對齊。爲什麼這樣? 下面是我的示例代碼:
$(document).ready(function() {
function makedraggable() {
$(".qitem2").draggable({
"revert": "invalid"
});
}
makedraggable();
$(".box1").droppable({
"accept": ".qitem2",
"drop": function(event, ui) {
if ($(this).find(".qitem2").length) {
var $presentChild = $(this).find(".qitem2"),
currChildId = $presentChild.attr("id"),
$currChildContainer = $("#" + currChildId + "-container");
$currChildContainer.append($presentChild);
$presentChild.removeAttr("style").removeClass("drag-center-in-droppable");
makedraggable();
}
$(ui.draggable).clone().appendTo(this).removeAttr("style").addClass("drag-center-in-droppable");
$(ui.draggable).remove();
}
})
function makedraggable1() {
$(".qitem3").draggable({
"revert": "invalid"
});
}
makedraggable1();
});
PHP代碼
<div id="drag_paragraph1">
<p style="display:inline;font-size:14px;line-height:200%">
In order to polymeric</p><div class="fancy nonEditable" draggable="true"><div class="box4 ui-droppable"></div></div>macromolecules into smaller portions,<div class="fancy nonEditable" draggable="true"><div class="box4 ui-droppable"></div></div>digestive enzymes play a vital role in the of<div class="fancy nonEditable" draggable="true"><div class="box4 ui-droppable"></div></div>absorption of nutrients in the body. Located in the digestive tracts in the bodies of animals, and in the trap in the bodies of carnivorous plants, they facilitate of food inside<div class="fancy nonEditable" draggable="true"><div class="box4 ui-droppable"></div></div>the cells.
<p></p>
</div>
<div id="qlist2">
<div id="di21-container" class="drag-container">
<div id="di21" class="qitem5 di1 ui-draggable ui-draggable-handle" style="position: relative;">
cccc </div>
</div>
<div id="di22-container" class="drag-container">
<div id="di22" class="qitem5 di1 ui-draggable ui-draggable-handle" style="position: relative;">
bbbb </div>
</div>
<div id="di23-container" class="drag-container">
<div id="di23" class="qitem5 di1 ui-draggable ui-draggable-handle" style="position: relative;">
aaaa </div>
</div>
<div id="di24-container" class="drag-container">
<div id="di24" class="qitem5 di1 ui-draggable ui-draggable-handle" style="position: relative;">
eeee </div>
</div>
<div id="di25-container" class="drag-container">
<div id="di25" class="qitem5 di1 ui-draggable ui-draggable-handle" style="position: relative;">
iiii </div>
</div>
<div id="di26-container" class="drag-container">
<div id="di26" class="qitem5 di1 ui-draggable ui-draggable-handle" style="position: relative;">
dddd </div>
</div>
<div id="di27-container" class="drag-container">
<div id="di27" class="qitem5 di1 ui-draggable ui-draggable-handle" style="position: relative;">
ffff </div>
</div>
</div>
以上是用於拖動和投擲的代碼。如果我在div框中設置了一些默認的單詞,那麼拖放操作就會被摺疊,爲什麼呢?如果有人知道解決方案,請幫助我。提前致謝。 工作https://jsfiddle.net/c62tpc45/2/