Reputation: 333
I am using Jquery Draggable code from this link
I am trying to drag an image within a DIV but it is getting dragged to the whole page. My code is as follows
<div>
<span class="move" id="draggable">
<img src="cropped/image_name.jpg"/>
</span>
</div>
I do not want this image to be draggable outside of the DIV. Rest of the code is working perfecrly. Please help me to solve this problem. Thanks in advance.
Upvotes: 0
Views: 87
Reputation:
you don't want it to be visible outside the parent element???
overflow:hidden
Upvotes: 1
Reputation: 57095
Working demo http://jsfiddle.net/cse_tushar/Lsc3r/1
$("#draggable img ").draggable({ containment: "#div1" });
Upvotes: 1
Reputation: 388316
Try using the containment option
$('#draggable img').draggable({
containment: $('#draggable').parent()
})
Upvotes: 3