Friday 15 March 2013

JQuery showing too many decimals -


I have this code for a progress bar but . Progress-label showing too many decimals, something like (2.020302032400%).

My code looks like this

  & lt; Script & gt; $ (Document) .ready (function () {$ ("# progressbar"). Progressbar ({value: 1}); $ ("# progressbar> .ui-progressbar-value"). Animate ({width: "37%"}, {step: function (width) {$ ('progress-label'). Text (width + '%');}}, 2000);}); & Lt; / Script & gt;   

How can I get rid of it for decades? Is it even possible that one percent increases? It is getting very fast now.

- ---------------------------------- Edited ------- -------- --------------------

With the reply of Brar, I have completed the code, if anyone Here's the solution:

  $ (document) .ready (function () {$ ("# progressbar"). Progressbar ({value: 1}); $ (" {Progressbar> .ui-progressbar-value "). {Width:" 37% "}, {duration: 10000, step: action (width) {$ ('progress-label'). Text (width.toFixed ( 0) + "%")}}}})});    

to specify the number of toFixed () method Use decimal places.

  $ ('Progress-label'). Text (width.toFixed (1) + '%'); }   

will display 1 digit after the decimal point.

No comments:

Post a Comment