获取Jquery进度条的值

Und*_*e2k 3 html jquery

我希望找到进度条的值,这样我就可以在每一步中增加一个百分比,但无论我尝试它还是说它未定义,或者在实例化对象之前无法调用该方法.

我试过的事情:

 alert($('progressbar:first').prop('progress-label')); 

 progressbarValue = progressbar.find( ".progress-label" ).val();
Run Code Online (Sandbox Code Playgroud)

HTML

<div id="progressbar"><div class="progress-label">Form Process</div></div>
Run Code Online (Sandbox Code Playgroud)
if(condition == true) {

    progressbar = $( "#progressbar" );
    progressbarValue = progressbar.find( ".ui-progressbar-value" );
    progressLabel = $( ".progress-label" );


    var size = parseInt($("#fieldWrapper .step").size(),10);
    var progress = 100/size ; 

 alert($('progressbar:first').prop('progress-label')); 
  progressbar.progressbar({
      value: progress,
      change: function() {
        progressLabel.text( progressbar.progressbar( "value" ) + "%" );

      },
      complete: function() {
        progressLabel.text( "Complete!" );
      }
    });

        progressbarValue.css({
          "background": '#' + Math.floor( Math.random() * 16777215 ).toString( 16 )
        });

}
Run Code Online (Sandbox Code Playgroud)

use*_*654 5

尝试使用progressbar小部件的值方法.

$("#progressbar").progressbar("value");
Run Code Online (Sandbox Code Playgroud)

http://api.jqueryui.com/progressbar/#method-value

请注意,您必须先前已启动进度条以获取其值.否则,该元素还不是进度条.

演示:http://jsfiddle.net/3sbTw/