JSFiddle - React, Tailwind, and code Playground
by Ali Soltani
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
<li>four</li>
<li>five</li>
<li>six</li>
</ul>
<p>hello
<span></span>hello
<span></span>hello
<span></span>
</p>
CSS
span {
width: 100px;
display: inline-block;
height: 20px;
background: #ffffff;
}
body {
font: 13px Verdana;
}
ul {
list-style: none;
padding: 10px;
background: yellow;
}
ul li {
display: inline-block;
margin: 0 10px;
padding: 10px;
background: rgb(0, 255, 213);
}
p {
padding: 10px;
background: rgb(255, 145, 0);
}
JavaScript
$(document).ready(function() {
$("span").droppable({
accept: "ul > li",
classes: {
"ui-droppable-hover": "ui-state-hover"
},
drop: function(event, ui) {
var dragedElement = ui.draggable.text();
$(this).addClass("ui-state-highlight");
$(this).html(dragedElement);
$(this).addClass('matched');
}
});
$("ul li").draggable({
helper:"clone",
revert: "invalid"
});
})