0

我基本上有一个按钮来删除一些东西,代码是:

$(document).on('click','.btn',function(){
    //code here
    //$t is the item to delete
    $t.remove();
});

现在我想在removeoron完成后执行以下代码:

if($('#bookmarks').is(':empty')){
    $('#bookmarks').css('visibility','hidden');
}

我尝试将其添加到.on

$t.on("remove", function () {
    if($('#bookmarks').is(':empty')){
        $('#bookmarks').css('visibility','hidden');
    }   
});

但这没有用。那么在项目完全删除后如何执行该功能?

4

2 回答 2

5

简单,调用后执行即可remove()

$(document).on('click','.btn',function(){
    //code here
    //$t is the item to delete
    $t.remove();

    //remove done, next
    if($('#bookmarks').is(':empty')){
        $('#bookmarks').css('visibility','hidden');
    }
});
于 2013-07-30T13:21:59.403 回答
0

尝试

$(document).on('click','.btn',function(){

$t.remove();

//remove done
if($('#bookmarks').is(':empty')){
    $('#bookmarks').hide();
}

});

于 2013-07-30T13:23:46.340 回答