这是我的Jquery:
$(".list").draggable({helper: 'clone', cursor: 'hand'});
$(".drop1").droppable({
accept: '.list',
hoverClass: 'dropareahover',
drop: function(ev, ui){
var targetId = $(this).attr("id");
var allTargets = $("#" + targetId, ".tble");
$("#" + targetId).each(function() {
//here i have to write the conditions.
});
}
});
我需要将内容放入特定区域。如果我把内容放在其他区域。它不会接受。
答案 0 :(得分:1)
这可能是你想要的吗? (jquery draggable的恢复选项)
$(".list" ).draggable({ helper: 'clone', cursor: 'hand', revert: 'invalid'});
来自:http://jqueryui.com/demos/draggable/
如果将revert设置为true,则元素将返回其起始位置 当拖动停止时。可能的字符串值:'valid','invalid'。如果 设置为无效,只有在没有拖动时才会发生恢复 放在一个可放置的。如果有效,那就是另一种方式。
代码示例
使用指定的revert选项初始化一个draggable。
$(".selector" ).draggable({ revert: true });