对于使用Jquery的每个和动画人物

时间:2014-03-05 14:52:26

标签: jquery foreach jquery-animate figures

我有6个div,其类名为“count”。 我试图复制这个:http://jsfiddle.net/4v2wK/

我只是试图为数字制作动画,但没有任何作用,这是我的代码:

$('.count').each(function(){
    $({someValue: 1000}).animate({someValue: this.value}, {
        duration: 6000,
        easing: 'swing', // can be anything
        step: function () { // called on every step
            // Update the element's text with rounded-up value:
            $(this).text(commaSeparateNumber(Math.round(this.someValue)));
        }
    });
});

非常感谢您的帮助,

伊莎贝尔,

1 个答案:

答案 0 :(得分:0)

我一直在寻找相同类型的脚本,这个脚本对我有用:

 $(document).ready(function(){

            $('.feature').each(function(){
                var el = $(this);
                $({someValue: 1}).animate({someValue: el.html()}, {
                    duration: 3000,
                    easing: 'swing',
                    step: function () {                     
                        el.html(Math.round(this.someValue));/**/
                    }
                });
            });

        });

希望它有所帮助...