简体   繁体   English

如何在不拖动的情况下触发drag()

[英]How to trigger drag() without dragging

I am using jQuery UI or more specific the draggable feature. 我正在使用jQuery UI或更具体的可拖动功能。 Is it possible to trigger drag() and tell the element to move/drag somewhere without doing it yourself? 是否可以触发drag()并告诉元素将其移动/拖动到某个位置而无需自己进行操作? Something like el.dragTo(position). 类似于el.dragTo(position)。

Thanks in advance! 提前致谢!

EDIT: I am kinda using the draggable function as a resizer. 编辑:我有点使用可拖动功能作为调整大小。 I have a 1px thin div between two other divs. 我在其他两个div之间有一个1px的div。 When i drag the div in either direction i resize the other two divs depending on the amount i dragged the drag-div. 当我向任一方向拖动div时,我会根据拖动拖动div的数量来调整其他两个div的大小。

Use jQuery animate() 使用jQuery animate()

$(element).animate({
    top: '10px',
    left: '30px'
});

Demo: http://jsfiddle.net/maniator/BXVx2/ 演示: http//jsfiddle.net/maniator/BXVx2/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在拖动一个jqueryUI可拖动元素时,触发对其他多个元素的拖动 - On dragging one jqueryUI draggable element trigger drag on other multiple elements 如何通过拖动JSXGraph中的另一个元素来拖动滑翔机 - How to drag a glider by dragging another element in JSXGraph 如何在不实际拖放的情况下使用jQuery UI Droppable触发Drop事件? - How do I trigger the Drop event with jQuery UI Droppable without actually dragging and dropping? 继续拖动事件而不将元素拖动到任意阈值以上 - Continue drag event without dragging an element further than an arbitrary threshold 如何手动触发jQuery drag()函数?比如$(element).trigger('drag'); - How to trigger jQuery drag() function manually? like $(element).trigger('drag'); Scriptaculous Drag:如何抵消拖动元素? - Scriptaculous Drag: How do I offset the dragging element? 如何在启用了拖放的div中启用鼠标拖动 - How to enable mouse dragging within a drag and drop enabled div 如何在使用Mapbox LeafLet拖动标记时获取标记拖动事件 - How to get marker drag event on dragging marker with mapbox LeafLet 如何在拖动过程中隐藏(或更改)不允许的拖动 cursor? - How can I hide (or change) the drag not allowed cursor during a dragging? 如何实现拖放操作,拖动子元素将拖动整个父元素 - How to implement drag and drop so dragging child element will drag whole parent element
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM