I have a progress bar on my page (Bootstrap) that looks like this:
<div id="theprogressbar" class="progress-bar progress-bar-u" role="progressbar" aria-valuenow="75%" aria-valuemin="0" aria-valuemax="100" style="width: 75%">
I would like to update it via jQuery, I have already done most of the work and calculated the new value I need to put into it, but am unsure of how to target the aria-valuenow
and the style="width: "
values.
Assuming my jQuery gives me the new value+% as a variable called newprogress
:
$('#theprogressbar'). *(please help me finish this line)* (newprogress)
When set, the valuetext string is announced instead of the valuenow numeric value. For example, if a slider represents the days of the week, so the day of the week's aria-valuenow is a number, the aria-valuetext property should be set to a string that makes the slider value understandable, such as "Monday".
The value of aria-valuenow is a decimal number. If the range is a set of numeric values, then aria-valuenow is one of those values. For example, if the range is [0, 1], a valid aria-valuenow is 0.5. A value outside the range, such as -2.5 or 1.1, is invalid.
$('#theprogressbar').attr('aria-valuenow', newprogress).css('width', newprogress);
value default is px if you want set % follow code below
$('#theprogressbar').attr('aria-valuenow', newprogress).css('width', newprogress+'%');
You could use
$('#theprogressbar').attr("aria-valuenow","the new value"); $('#theprogressbar').attr("style","width:"+theincrementingvalue);
Or you could use .css in jquery http://api.jquery.com/css/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With