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?
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.
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.
Demo - http://jsfiddle.net/fJxGG/1/
Both seem to work on Chrome & FF -
$('#progBar').attr('value',50);
$('#progBar').val(70);
$('#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">
have you tried $("#progBar").attr("value", 15);
?
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