Thursday 15 March 2012

javascript - Method will roundoff the final sum to 2 decimal places - jquery -



javascript - Method will roundoff the final sum to 2 decimal places - jquery -

i have code:

class="snippet-code-html lang-html prettyprint-override"> <script> $(document).ready(function() { function compute() { var = $('#a').val(); var b = $('#b').val(); var total = * b + (8 / 100) * ; $('#total').val(total); } $('#a, #b').change(compute); }); </script>

¿as can utilize command (.tofixed) ? display roundoff end sum 2 decimal places.

thanks.

you can utilize ".tofixed(2)" wil round of 2 decimals. homecoming string instead of float/decimal number.

jsfiddle see link illustration code work

javascript jquery

No comments:

Post a Comment