Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery to change values of progress-bar "aria-valuenow" attribute and CSS "width" property

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) 
like image 447
Ray_Hack Avatar asked Jun 04 '15 09:06

Ray_Hack


People also ask

How do you use aria-Valuenow?

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".

What is Aria-Valuenow?

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.


2 Answers

$('#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+'%'); 
like image 120
Denis Slonovschi Avatar answered Sep 18 '22 06:09

Denis Slonovschi


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/

like image 27
jameshwart lopez Avatar answered Sep 19 '22 06:09

jameshwart lopez