简体   繁体   English

在按钮拖动上拖动父div

[英]Drag parent div on button drag

I have a button inside div, I make this button dragable, And my div is also dragable. 我在div中有一个按钮,使此按钮可拖动,而我的div也可拖动。 I have some event on div drag which saves current position of div. 我在div拖动上有一些事件可以保存div的当前位置。 I want to trigger drag of div on button div. 我想在按钮div上触发div的拖动。 Means when i drag button then my div also drag to the same position and save the positions. 表示当我拖动按钮时,我的div也拖动到相同位置并保存位置。

here is sample code:- 这是示例代码:-

$(".fieldClass").draggable().resizable();
$('#updateButtonId').draggable({cancel:false,drag: function (e, ui) {
      $("#field_1_updateButton").trigger('drag');
}}); 

JSfiddle:- 的jsfiddle: -

http://jsfiddle.net/nbt89x5f/1/ http://jsfiddle.net/nbt89x5f/1/

Try this 尝试这个

 $(".fieldClass").draggable().resizable(); $('#field_1_updateButton').draggable({ cancel: false, drag: function (e, ui) { $("#updateButtonId").trigger('drag'); } }); 

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM