0

I am not getting how can I update progress bar. Here is my code,

socket.on('value',function(data){
    console.log(data); // For example, this prints value '10'
 // Here i have to update progress bar.
}

I want to divide value by 10, equally and adjust the progress width to 100%. Can anyone help me doing this? Is it possible? I am new to this concept. Please help me solving this.

2
  • Let me clarify: you have a <progress> element (developer.mozilla.org/ru/docs/Web/HTML/Element/progress), and you need to update it inside your callback? It's not clear from the question Commented Sep 26, 2016 at 9:58
  • This question is unclear. Would you please add more context, and some more examples of what you have tried so far? Commented Sep 26, 2016 at 10:01

1 Answer 1

2

If you are using <progress> element, you can update it inside your callback like that:

// suppose your <progress> element is defined this way:
<progress min=0 max=100 id="myProgressBar"></progress>

// updating it:
socket.on('value',function(data){
    console.log(data); // For example, this prints value '10'
    $("#myProgressBar").val(data / 10) // here is the one way to update it
}

Also you can omit dividing by 10 (and just call $("#myProgressBar").val(data) ) and just specify max=10 (or whatever your maximum value is) inside your element's attributes.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.