Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using jQuery with HTML5 progress bar

Tags:

html

jquery

I want to use jQuery to update the value of my progress bar that I am using.

<progress id="progBar" value="10" max="100">

I want to update this everytime someone push a button to change the value up by one but I don't know the code.

I have tried using val(15) .progressbar({ value: 15 }) but it won't update to 15.

Can someone give me a solution?

like image 200
Devyn Avatar asked Oct 18 '11 07:10

Devyn


People also ask

How do I add a progress bar in HTML?

Use the <progress> tag to create a progress bar in HTML. The HTML <progress> tag specifies a completion progress of a task. It is displayed as a progress bar. The value of progress bar can be manipulated by JavaScript.

What is progress bar in jQuery?

It is the collection of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Progress bars tells us the percentage of our task completed and how much it is left. It is a GUI widget which creates a type of interaction between the user and the system.


3 Answers

Demo - http://jsfiddle.net/fJxGG/1/

Both seem to work on Chrome & FF -

$('#progBar').attr('value',50);
$('#progBar').val(70);
like image 58
Jayendra Avatar answered Oct 22 '22 12:10

Jayendra


$('#click').click(function() {
  // Get progress bar current value and add with 1;
  var curr_val = $('#progBar').val();
  var new_val = Number(curr_val) + 1;
  $('#progBar').val(new_val);
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<button type="button" id="click">Click me</button>
<progress id="progBar" value="10" max="100">
like image 3
Nadeem Shinwari Avatar answered Oct 22 '22 13:10

Nadeem Shinwari


have you tried $("#progBar").attr("value", 15); ?

like image 1
alediaferia Avatar answered Oct 22 '22 14:10

alediaferia