JSFiddle - React, Tailwind, and code Playground

by tmyie

HTML

<div class="square"></div>
<div class="circle" draggable="true">
    
</div>

CSS

.circle {
    border-radius: 45px;
    width: 45px; height: 45px;
    position: relative;
    cursor: pointer;
    background-color: red;
     cursor: -webkit-grab;
}
.square {
    width: 60px;
    height: 60px;
    position: relative;
    border: 4px solid green;
    left: 100px;
    text-align: center;
}
.square .circle {
    text-align: center;
    background-color: green;
    margin: 0 auto;
}

JavaScript

// ondragover 
 //ondragleave 
 //ondrop 
 
$('.circle').on('dragstart', function () {
    console.log('drag start!');
});

$('.square').on('dragover', function (e) {
    e.preventDefault();
    //$(this).css('background-color', 'red');
    $('.circle').appendTo(this);
});

$('.square').on('dragleave', function (e) {
    e.preventDefault();
 });

$('.square').on('drop', function (e) {
    console.log('drop');
});