how to trigger dragging of image with drag of other image using jquery

主宰稳场 提交于 2019-12-11 23:53:55

问题


I am working with jquery for dragging of images. Below is my code

        $( "#imgMaster" ). draggable
        ({ 
            axis: "y", 
            containment:[0,170,0,430],  
            start: function(event, ui)
                            {
                                $("#imgFrontLeft").trigger('draggable');
                            }

        });

        $( "#imgFrontLeft" ). draggable
        ({ 
            axis: "y" ,
            containment:[0,162,0,290],
        });

My requirement is that, on drag of #imgMaster, #imgFrontLeft must be dragged. Both the images are dragged independently. Kindly help me with , how could i meet my requirement.


回答1:


Take a look this Fiddle link this will help you to get the answer for synchronizing two images for dragging. you can use this

 $("#imgFrontLeft").css('left',ui.position.left); 
 $("#imgFrontLeft").css('top',ui.position.top); 

in your code to drag the images, i hope this will help you more.



来源:https://stackoverflow.com/questions/14809283/how-to-trigger-dragging-of-image-with-drag-of-other-image-using-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!