Jquery ui draggable drag parent div

As the title says, I want to drag the parent div, let's say I have this structure

<div class="parent"> <divc class="draggable"></div> </div> $(".draggable").draggable(); 

So how can I drag .parent instead of .draggable .

And no, I don’t want to do .parent draggable instead of .draggable , since it will be a window that will be dragged in only one place.

+8
jquery jquery-ui
source share
1 answer

Are you trying to make the child a drag handler?

 $(".parent").draggable({ handle: ".draggable" }); 

This will cause the whole parent to drag, but only use the draggable div as a binding.

jsFiddle Demo

Link:

http://jqueryui.com/demos/draggable/#handle

+17
source share

All Articles