我动态创建了很多div并动态添加它们。但是有一些问题。当我拖动到类可以删除的特定div时,我想恢复false OR无效。我该怎么做动态。
<img class="droppable" src=""></img>
<div id="pi"></div>
<input type="button" id="ok">
<script>
var new_id=0;
$("#ok").click(function () {
new_id = new_id + 1;
var increase = new_id;
var hidden = "<div class='hidden" + increase + " list-group'>
<span class='one" + increase + " list-group-item'></span>
<span class='two" + increase + " list-group-item'></span>
<span class='three" + increase + " list-group-item'></span>
<span class='four" + increase + " list-group-item'></span>";
$(".hidden" + increase + "").draggable({ revert: true });//here revert invalid make error
$("#pi").append(hidden);
});
</script>
我也试过这个,但它不起作用
$(".droppable").mouseover(function(){
$(".draggable").draggable("option","revert","false");
});
答案 0 :(得分:0)
只有在致电.draggable
之后才会追加元素。切换这些电话的位置:
$('#api').append(hidden);
$(".hidden" + increase + "").draggable({ revert: true });