我希望能够通过拖动特定的内部 div 来移动外部 div。只有内部 div 才能移动外部 div。
我尝试在外部 div 上使用 Jquery 的 draggable()
方法,但这允许用户通过单击并拖动外部 div 内的任意位置来移动外部 div,这会阻止用户突出显示某些文本用于复制。
我已经设置了一个 jsFiddle here .
如何在单击并拖动特定内部 div 时使外部 div 只能拖动?
最佳答案
添加handle
选项
handle
If specified, restricts dragging from starting unless the mousedown occurs on the specified element(s). Only elements that descend from the draggable element are permitted.
$("#outer").draggable({
handle: "#inner"
});
关于javascript - 如何使用内部 div 拖动其外部父 div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32121784/