您也可以尝试以下解决方案。
<script type="text/javascript">
$(document).ready(function(){
$('.srcfield').draggable({
revert: true
});
$('#trash').droppable({
accept : ".srcfield",
over: function(){
$(this).removeClass('out').addClass('over');
},`enter code here`
out: function(){
$(this).removeClass('over').addClass('out');
},
drop: function(ev, ui){
//var answer = confirm('Delete this item?');
var theTitle = $(ui.draggable).attr("title");
$(this).html("<u>"+theTitle+"</u><br/> is deleted!");
}
});
});
</script>
<body>
<div id="trash" class="out">
<span>Trash</span>
</div>
<div id="sourcefields">
<div class="srcfield" title="First Name"><span>First Name</span></div>
<div class="srcfield" title="Last Name"><span>Last Name</span></div>
<div class="srcfield" title="Age"><span>Age</span></div>
</div>
</body>