As I delve into implementing drag and drop functionality with JQuery, I encounter a peculiar issue. I have set up 3 'draggable' divs and corresponding 3 'droppable' divs. The intended behavior is for each draggable element to be accepted by its respective droppable counterpart (e.g., draggable1 should be accepted by droppable1). However, the functionality only seems to work for one pair of divs - draggable1 and droppable1. The other pairs do not function as expected.
Upon closer inspection, it appears that the problem may stem from the CSS positioning settings. When I refrain from defining margin properties for the individual divs, the drag and drop works seamlessly. Yet, when I attempt to reposition the divs, the functionality breaks down.
For reference, here's a jsfiddle link showcasing my implementation: https://jsfiddle.net/3ews8j8x/
Below are snippets of the HTML and CSS code I'm utilizing:
<center><h3>Drag and Drop</h3></center>
<div class="wrap">
<div class="draggables" id="draggable1"></div><br>
<div class="draggables" id="draggable2"></div><br>
<div class="draggables" id="draggable3"></div><br>
</div>
<div id="droppable1"></div>
<div id="droppable2"></div>
<div id="droppable3"></div>
The provided CSS styles the elements accordingly based on their IDs, but altering the positioning seems to disrupt the drag and drop feature. Further details can be found in the linked JavaScript code.
I seek assistance in understanding why adjusting the div positions interferes with the drag and drop functionality. Is this limitation inherent or am I overlooking something crucial? Your insights would be invaluable as I've grappled with this issue for several days now.
Your support is greatly appreciated.