Get jquery progress bar value
I want to find the value of the progress bar so that I can increment it by a percentage at each step, but no matter what I tried, either it said it was undefined or the method could not be called before the object was instantiated.
Things I've tried:
alert($('progressbar:first').prop('progress-label'));
progressbarValue = progressbar.find( ".progress-label" ).val();
Html
<div id="progressbar"><div class="progress-label">Form Process</div></div>
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 )
});
}
+3
Undermine2k
source
to share
1 answer
Try using the progressbar widget values method.
$("#progressbar").progressbar("value");
http://api.jqueryui.com/progressbar/#method-value
Note that you must have already run the progress bar earlier to get its value. Otherwise, the element has not yet been reached.
Demo: http://jsfiddle.net/3sbTw/
+5
Kevin B
source
to share