0

すべてのもののフェードインが完了したときに何かを行う (アラート) 方法を見つけようとしています。私の構文が良くないのでしょうか?

    $.fn.showdelay = function(){
            var delay = 0;
            return this.each(function(){
                $(this).delay(delay).fadeIn(200);
                delay += 200;
            },
            function(){ 
                alert('done!');
            });
        };
    $item.delay(500).showdelay();
4

3 に答える 3

1

メソッドcallback function parameterで を使用しfadeInます。

$.fn.showdelay = function(){
        var delay = 0, count = $(this).length - 1;

        return this.each(function(i){
            $(this).delay(delay).fadeIn(200, function() {
                if(i == count) alert('something');
            });
            delay += 200;
        });
    };
$item.delay(500).showdelay();

http://api.jquery.com/fadeIn/

于 2012-02-20T01:52:13.987 に答える
0

fadeIn()アニメーションが終了したときに実行されるコールバックを使用できます。

$('#el').fadeIn('fast', function(){ //Callback });
于 2012-02-20T01:53:52.100 に答える
0

fadeIn で提供されているコールバック メソッドを使用します。

$.fn.showdelay = function() {
var delay = 0;
return this.each(function(){
    $(this).fadeIn(200, function() { 
        alert('done!'); 
    });
    delay += 200;
});
$item.delay(500).showdelay();
于 2012-02-20T02:10:58.427 に答える