代码之家  ›  专栏  ›  技术社区  ›  fabrik

删除前的jQuery突出显示效果()

  •  7
  • fabrik  · 技术社区  · 14 年前

    请考虑以下片段:

    $('.remove_item').click(function(e) {
        var _item = $(this).closest('.cart_item');
        if(confirm('Biztosan törölhetem a terméket a kosárból?')) {
            _item.effect('highlight', {}, 100).stop().fadeOut('fast');
            _item.remove();
    ...
    

    .remove() )它。如果我没有 项目,突出显示工作。

    3 回复  |  直到 12 年前
        1
  •  17
  •   lonesomeday    14 年前

    您可以使用的回调功能 effect fadeOut 要在第一个操作完成时执行操作:

    _item.effect('highlight', {}, 100, function(){
        $(this).fadeOut('fast', function(){
            $(this).remove();
        });
    });
    

    上面写着“突出显示 _item . 完成后,将其淡出。完成后,将其移除。”

        2
  •  5
  •   RobertPitt    14 年前

    你应该可以在淡出时指定回调:

    $('.remove_item').click(function(){
        if(confirm('Biztosan törölhetem a terméket a kosárból?'))
        {
             $(this).closest('.cart_item').fadeOut(500, function() { $(this).remove(); });
        }
    });
    

    希望这有帮助。

        3
  •  0
  •   Simon    14 年前

    您需要对.remove()进行排队

    _item.queue( function() { $(this).remove(); });