jquery - 元素掉落时如何执行效果

问题描述:

我想在用户放下物品时执行效果。我怎样才能做到这一点?假设我想使用“反弹”效果。jquery - 元素掉落时如何执行效果

var drop1 = 1; 
var drop2 = 2; 
var liit = 3; 
var counter = 0; 

$('.container').droppable({ 
    accept: '.item', 
    drop: function(event, div) { 

     counter++; 

     // here I would like to put a function that 
     // the dropped element bounces up and down before the alert. 
     if (counter == hit1) { 
      alert("You dropped on item"); 
     } 

     else if (counter == hit2) { 
      alert("You dropped another item"); 
     } 
    } 
}); 
+0

你现在解决问题了吗? – eeya

我相信你在寻找下降事件。

该文档可以在此页面找到。

http://api.jqueryui.com/droppable/#event-drop

$(".item").on("drop", function(event, ui) { 
    alert("You dropped on item"); 
});