0

What I want to do:

So I want to fire a function that resizes the containing div when one of its children are deleted BUT only after its done fading out.

The Problem:

The wrapper div is being resized ( addToSlider(-1) ) before the 200 millisecond fade is done.

Here is my code:

$('.you img[imgid="' + deletedrow.id + '"]').parent().fadeOut(200, addToSlider(-1));
4

1 回答 1

2
$('.you img[imgid="' + deletedrow.id + '"]').parent().fadeOut(200, function() {
    addToSlider(-1);
});

当使用括号调用函数时,它会立即执行,因此要传递参数,您需要另一个匿名函数。

但是,您可以在不传递参数的情况下直接引用该函数,如果可以的话,我猜它不会并且您需要传递-1,但这就是您这样做的方式:

$('.you img[imgid="' + deletedrow.id + '"]').parent().fadeOut(200, addToSlider);
于 2013-05-11T20:36:31.653 回答