I have the following jQuery:
我有以下jQuery:
$(document).ready(function(){
$(".element").draggable();
$(".element").droppable({
drop: function() {
alert('dropped');
}
});
});
Anything with the class of 'element' can be manipulated and dragged around the page. I want to be able to find the html contents of the element that is being dragged and the element that is being dropped and use them where "alert('dropped');" is, so I could do something like:
任何具有“元素”类的东西都可以在页面上进行操作和拖动。我希望能够找到被拖动的元素的html内容和被删除的元素,并在“alert('dropped');”中使用它们。是的,所以我可以这样做:
alert(firstelement+ ' was dropped on ' +secondelement);
Any Ideas?
1 个解决方案
#1
You need to add parameters to your drop callback.
您需要为drop回调添加参数。
drop : function(event, ui) {
var droppable = $(this);
var draggable = ui.draggable;
alert(droppable.attr('id') + " was dropped on " + draggable.attr('id'));
}
#1
You need to add parameters to your drop callback.
您需要为drop回调添加参数。
drop : function(event, ui) {
var droppable = $(this);
var draggable = ui.draggable;
alert(droppable.attr('id') + " was dropped on " + draggable.attr('id'));
}