2015-12-03 141 views
0

所以我想使用jQueryui及其可拖拽/ droppable組合,並且當我將某個項目放入某個容器時,我想向該項目添加一個類。那可能嗎?到目前爲止,我設法做的是向放下可拖動項目的容器中添加一個類。但那不是我想要的。jQueryui可拖拽項目類

這是我目前工作的筆:http://codepen.io/zmuci/pen/Rrbvgg

<div class="categories"> 
    <div class="categorie">first categorie</div> 
    <div class="categorie">second categorie</div> 
    <div class="categorie">third categorie</div> 
    <div class="categorie">forth categorie</div> 
    <div class="categorie">fifth categorie</div> 
    <div class="categorie">sixth categorie</div> 
    <div class="categorie">seventh categorie</div> 
</div> 

<div class="grid"> 
    <div class="grid-item grid-item-1"> 
    <div class="grid-item-inner"></div> 
    </div> 
    <div class="grid-item grid-item-2"> 
    <div class="grid-item-inner"></div> 
    </div> 
    <div class="grid-item grid-item-3"> 
    <div class="grid-item-inner"></div> 
    </div> 
    <div class="grid-item grid-item-4"> 
    <div class="grid-item-inner"></div> 
    </div> 
    <div class="grid-item grid-item-5"> 
    <div class="grid-item-inner"></div> 
    </div> 
    <div class="grid-item grid-item-6"> 
    <div class="grid-item-inner"></div> 
    </div> 
    <div class="grid-item grid-item-7"> 
    <div class="grid-item-inner"></div> 
    </div> 
    <div class="grid-item grid-item-8"> 
    <div class="grid-item-inner"></div> 
    </div> 
    <div class="grid-item grid-item-9"> 
    <div class="grid-item-inner"></div> 
    </div> 
</div> 

回答

2

在降功能使用。

$(ui.draggable).addClass('newClass') 
+0

是的,就是這樣。非常感謝。 – zmuci

+0

沒問題:)高興地幫忙:d – vivid

相關問題