javascript - Drag child and parent together -


i've got div structure below.

<div id="wrapper">    <div id="innerwrapper">       <div id="obj"></div>    </div> </div> 

currently i'm using jquery's draggable move div around.

jquery('#obj').draggable(); 

now i'm in situation need drag #wrapper dragging #obj. how can this? want able drag #obj , drag #wrapper together.

when this

jquery('#wrapper').draggable(); 

it not respond on touch devices maybe because #obj overlapping #wrapper

you can use handle option in draggable ui allow restrict parent getting dragged unless mousedown occurs on specified element(s) in child.

for code can do:

jquery( "#wrapper" ).draggable({ handle: "div#obj" });

for code reference : http://jsfiddle.net/xbb5x/8862/

for library reference: http://jqueryui.com/draggable/#handle


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -