0

我有一点进度条脚本。它工作正常,但在页面加载时运行。我想在屏幕上可见栏时运行动画(如果进度条在选项卡中,它也应该工作)。我怎样才能得到这个?

这是脚本:

setTimeout(function(){

    $('.skill-bar .skill-bar-content').each(function() {
        var me = $(this);
        var perc = me.attr("data-percentage");

        var current_perc = 0;

        var progress = setInterval(function() {
            if (current_perc>=perc) {
                clearInterval(progress);
            } else {
                current_perc +=1;
                me.css('width', (current_perc)+'%');
            }

            me.text((current_perc)+'%');

        }, 10);

    });

},10);

jsFiddle:http: //jsfiddle.net/fUyYL/

4

1 回答 1

0

像这样的东西?http://jsfiddle.net/fUyYL/1/

var ele = $('#skill-bars');
if( ele.is(':visible') ) {
    ...
}
于 2013-01-25T12:16:29.070 回答