In JQuery UI, I am trying to restrict draggable element into particular elements which are present inside the container (.container
).
Even I have tried with containment
as array of values it is working but in my case I will be unaware of the .container
height and width. Please suggest me which will the right approach to do this one.
<div class="container">
<div class="restricted-field-1">should be restricted here</div>
<div class="dragme">DRAG ME</div>
<div class="restricted-field-2">should be restricted here</div>
</div>
$(".dragme").draggable({
containment: ".container"
});