如何获得可拖动的attr? (只有我拖的那个) ui和ui.draggable不起作用。请解释何时使用每一个 我一直在寻找,我没有看到解决方案: http://api.jqueryui.com/draggable/#event-drag
$( ".blue" ).draggable(
{ drag: function( event, ui ) { // mentre arrossego
//var drag = ui.position.left; //ok
//var id = this.attr('data-id'); //no
//var id = ui.attr('data-id'); //no
//var id = ui.draggable.attr("data-id")//no
$("#check").html(id);
}
});
.blue {
float:left;
display:inline-block;
width:30px; height:30px;
margin:10px;
background:blue;
cursor:pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="blue" data-id="220"></div>
<div class="blue" data-id="221"></div>