2015-04-14 69 views
0

我正在尝试显示进度百分比。因此,我给出了百分比类百分比来显示它,进度条的id是“progressbar”。我的js代码是,使用jquery显示进度条百分比

$("#progressbar").progressbar({ 
    value: 50 
}); 

$(document).ready(function() { 

    $("#progressbar").progressbar({ 
    value: 0 
    }); 
    var progress = setInterval(function() { 
    var currentVal = $("#progressbar").progressbar("value"); 
    var nextVal = currentVal + 1; 
    $('#percentage').text(currentVal); 
    if (nextVal > 90) { 
     clearInterval(progress); 
    } else { 
     $("#progressbar").progressbar({ 
     value: nextVal 
     }); 
    } 

    }, 100); 
}); 

现在,我怎么提前显示在#percentage

感谢百分比。

+0

什么问题?你在控制台中收到某种错误吗?或者显示不正确,还是根本不显示? – jmunsch

+0

[有没有办法显示jQuery UI Progressbar中的百分比数字?](http://stackoverflow.com/questions/3896891/is-there-a-way-to-show-the-percentage- number-inside-the-jquery-ui-progressbar) –

+0

进度条是可见的。但我不知道如何显示它的百分比所以我用一个跨度与ID'百分比'。如何显示它的百分比? –

回答

0

是不是

var currentVal = $("#progressbar").progressbar("option", "value"); 

应该是

var currentVal = $("#progressbar").progressbar("value"); 

这些应该是你的关卡

  • 包括jQuery的。
  • 包含jQuery脚本之后的jQuery-ui。
  • 包括css
+0

Thanq我纠正它,但是,我想要的是显示百分比 –