Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在animate()之后使用jQuery text()时无法正常工作_Javascript_Jquery - Fatal编程技术网

Javascript 在animate()之后使用jQuery text()时无法正常工作

Javascript 在animate()之后使用jQuery text()时无法正常工作,javascript,jquery,Javascript,Jquery,我正在尝试制作一个动画进度条,目前为止我有以下代码: HTML 问题是text()仅在所有动画完成后才会更改,因此,您无法看到(1%)、(2%、(3%)等,您只能在三个动画完成时看到(3%) 提前感谢实际上,它会在动画开始之前更改文本,如果您希望在动画之后发生某些事情,请使用动画回调 $(document).ready(function(){ $('button').click(function(){ $('.loader').fadeIn(1200);

我正在尝试制作一个动画进度条,目前为止我有以下代码:

HTML

问题是text()仅在所有动画完成后才会更改,因此,您无法看到(1%)、(2%、(3%)等,您只能在三个动画完成时看到(3%)


提前感谢

实际上,它会在动画开始之前更改文本,如果您希望在动画之后发生某些事情,请使用动画回调

$(document).ready(function(){
        $('button').click(function(){
            $('.loader').fadeIn(1200);

            $('.bar-value').animate({width: '+=1%'},100, function(){ 
                $('.progress').text("1%");
            });
            $('.bar-value').animate({width: '+=1%'},100, function(){ 
                $('.progress').text("2%");
            });
            $('.bar-value').animate({width: '+=1%'},100, function(){ 
                $('.progress').text("3%");
            });
        }); 
});

实际上,它在动画开始之前更改文本,如果您希望在动画之后发生某些事情,请使用动画回调

$(document).ready(function(){
        $('button').click(function(){
            $('.loader').fadeIn(1200);

            $('.bar-value').animate({width: '+=1%'},100, function(){ 
                $('.progress').text("1%");
            });
            $('.bar-value').animate({width: '+=1%'},100, function(){ 
                $('.progress').text("2%");
            });
            $('.bar-value').animate({width: '+=1%'},100, function(){ 
                $('.progress').text("3%");
            });
        }); 
});

实际上,它在动画开始之前更改文本,如果您希望在动画之后发生某些事情,请使用动画回调

$(document).ready(function(){
        $('button').click(function(){
            $('.loader').fadeIn(1200);

            $('.bar-value').animate({width: '+=1%'},100, function(){ 
                $('.progress').text("1%");
            });
            $('.bar-value').animate({width: '+=1%'},100, function(){ 
                $('.progress').text("2%");
            });
            $('.bar-value').animate({width: '+=1%'},100, function(){ 
                $('.progress').text("3%");
            });
        }); 
});

实际上,它在动画开始之前更改文本,如果您希望在动画之后发生某些事情,请使用动画回调

$(document).ready(function(){
        $('button').click(function(){
            $('.loader').fadeIn(1200);

            $('.bar-value').animate({width: '+=1%'},100, function(){ 
                $('.progress').text("1%");
            });
            $('.bar-value').animate({width: '+=1%'},100, function(){ 
                $('.progress').text("2%");
            });
            $('.bar-value').animate({width: '+=1%'},100, function(){ 
                $('.progress').text("3%");
            });
        }); 
});

animate在动画完成时接受回调animate在动画完成时接受回调animate在动画完成时接受回调animate在动画完成时接受回调