【发布时间】:2018-04-22 00:40:28
【问题描述】:
我下面的代码大部分都在工作,但是当可拖动项目被拖出可放置区域时,它似乎被破坏了。我不认为这是 jQuery 文档中的默认功能。我在这里遗漏了什么吗?
$( function() {
$(".draggable_' . $question_id . '").draggable();
$(".droppable_' . $question_id . '").droppable({
activeClass:"ui-state-active",
accept:".draggable_' . $question_id . '",
out: function(event,ui) {
$(this).text(\'Drop selections here\'); //Put the "placeholder" back
},
drop: function(event,ui) {
$(this).text(\'\'); //Clear out the "placeholder"
$(ui.draggable).detach().css({top: 0,left: 0}).appendTo(this); //Make the draggable snap into the droppable
}
});
});
注意:这实际上是由 PHP 响应的。
【问题讨论】:
-
可以在codepen.io添加html代码或者创建笔
标签: jquery draggable droppable