JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://threedubmedia.com/inc/js/jquery.event.drag-2.2.js"></script>
<p>Drag the first square, the two others are going to drag with it</p>
<div id="test" class="drag" style="left:20px;">Square 1</div>
<div class="drag yellow" style="left:100px;"></div>
<div class="drag red" style="left:180px;"></div>
CSS
.drag {
position: absolute;
border: 1px solid #89B;
background: #BCE;
height: 58px;
width: 58px;
cursor: move;
top: 120px;
}
.red {
background-color: red;
}
.yellow {
background-color: yellow;
}
JavaScript
$('.drag').drag("init", function(ev, dd) {
if (this.id == "test") {
return $(".drag").addClass("selected");
}
}).drag(function(ev, dd) {
if (ev.target.id == "test") {
$(this).css({
top: dd.offsetY,
left: dd.offsetX
});
}
});