2013-01-24 65 views
2

有沒有什麼辦法可以一次將多個變量傳遞給Jquery.droppable函數,而不是僅僅使用相同的函數減速兩次,但名稱不同?jquery droppable函數參數

或者這不能正常工作?

因此,像

var $Monday = $("#Monday"); 
var $Tuesday = $("#Tuesday"); 


$Monday.droppable, $Tuesday.droppable({  
    accept: "#gallery > li",  
    activeClass: "ui-state-highlight",  
    drop: function(event, ui) { 
     } 

,而不是

$Monday.droppable({  
    accept: "#gallery > li",  
    activeClass: "ui-state-highlight",  
    drop: function(event, ui) { 
     } 

$Tuesday.droppable({  
    accept: "#gallery > li",  
    activeClass: "ui-state-highlight",  
    drop: function(event, ui) { 
     } 
+0

你試過$(「#星期一,#Tuesday 「).droppable(...),然後檢查事件信息? – Dave

回答

2

看看。新增()

$Monday.add($Tuesday).doStuff(...) 
+0

這很好,謝謝 – Edward