0

我有一个只显示其背景图像的 div:

  .foo
{
 height: 55px; width: 33px;
background: url('../images/foo.png');
 background-repeat: no-repeat; 
background-position:center; 
background-size: contain;
-moz-background-size: contain;
 color: transparent;
}

我想把它缩小到高度:1px;width: 33px,然后,当收缩完成时,通过在动画完成时调用回调函数将其从 DOM 中移除。

我试过 switchClass 但删除 .foo 会删除背景图像,并且 div 会立即缩小,而不是超过指定的持续时间,并且回调函数会立即触发。

4

1 回答 1

2

使用带有回调函数的jQuery.animate :

$(".foo").animate({ height: 1 }, 500, function(){
    $(this).remove();
});

500以毫秒为单位的持续时间在哪里。

于 2013-10-04T21:57:29.073 回答