how to get class/id from ui & event
How to get id & class name of any element from ui & event
of any function. please see below for clear understandin开发者_Python百科g .
<div class"drag-class" id="drag1"> </div>
<div class"drag-class" id="drag2"> </div>
<div class"drop-class" id="drop1"> </div>
<div class"drop-class" id="drop2"> </div>
JS:
$(function(){
$('.drag-class').draggable();
$('.drop-class').droppable(function(){
accept: '.drag-class'.
drop: function(ui,event){
/*here i want to know the id of drag-class & drop-class element element*/
}
});
});'
From the docs -
In the callback, $(this) represents the droppable the draggable is dropped on. ui.draggable represents the draggable.
this.id
and this.className
should contain what you're looking for.
精彩评论