0

我有一个纸娃娃库存。就像暗黑破坏神,你有元素,你把盔甲拖到你的角色上。盔甲放入的盒子是可分类的。当它收到时,我需要知道说“盔甲”插槽中是否已经有一个物品,所以它可以在收到新盔甲之前移除它。

所有插槽都是同一类。

会不会是这样的

$(".slot").sortable({
    receive: function(){
        $(this).parent().children();
    }
 });

或者

 $(this).sibling();
4

1 回答 1

0

你可以检查一个元素是否有孩子$(this).children().length > 0

例如:

if ($(this).children().length > 0)
{
    //has children
}
{
    //childless
}
于 2012-10-29T17:11:40.067 回答