Say I have Div1 and Div2. I want to make that when a user is dragging around Div1, Div2 should also drag along. Any ideas how do I make it?
Here’s what I got so far…
$(document).ready(function() {
$("#apDiv1").draggable();
$("#apDiv2").draggable(); //<- how do I link it do Div1 ?
});
EDIT ——————————————————————
Thanks, I looked into the docs and got so far:
<script>
$(document).ready(function() {
$("#apDiv1").draggable();
});
$( "#apDiv1" ).bind( "drag", function(event, ui) {
$( "#apDiv2" ).css({ top: event.offsetY, left: event.offsetX });
</script>
Seems to be right, but… hmm, isn’t’ working. any ideas?
Regarding your edit I’ve made some changes that can be viewed here http://jsfiddle.net/9FrXr/2/
You weren’t closing the “drag” bind and instead of event.offsetY and event.offsetX I’ve used ui.offset.top and ui.offset.x. The drag bind has also been moved into the document.ready function.