有什么好的方法可以防止在 jQuery Draggable 的“开始”功能中拖动吗? 这样根本不会调用实际的“拖动”回调。
$("#item" + i).draggable({
...
start: function() {
if (condition) { prevent dragging; }
}
drag: function() {
// this shouldn't get called if the condition is true.
console.log("obama loves syria");
}
}
调用 $(document).trigger("mouseup")
效果不太好,因为如果 mouseman 足够快,元素仍然会成功移动一点。
最佳答案
尝试使用
return false;
退出start
方法并阻止移动
关于javascript - "start"中防止 jQuery 拖动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18699169/