There are two divs of the same size, but in different places.
There is a code that starts dragging on these elements.
$(function() { $('.div1, .div2').draggable({ axis: 'x', cursor: 'pointer', cursorAt: 'pointer', drag: function(event, ui) { var left = ui.position.left, offsetWidth = ($(this).width() - $(this).parent().width()) * -1; if (left > 0) { ui.position.left = 0; } if (offsetWidth > left) { ui.position.left = offsetWidth; } } }); }); Tell me, please, how to make so that when dragging the first div1, the second one is automatically dragged and vice versa.