jQueryui可拖动项目类

时间:2015-12-03 11:08:07

标签: javascript jquery css jquery-ui

所以我想使用jQueryui及其draggable / droppable组合,当我将一个项目放入某个容器时,我想要将一个类添加到我拖动的那个项目中。那可能吗?到目前为止,我设法做的是在容器中添加一个类,我已将可拖动的项目删除。但那不是我想要的。

以下是我正在处理的笔: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>

1 个答案:

答案 0 :(得分:2)

drop函数中的

使用它。

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