Introduction:
Here I will explain how to use jQuery to round off numbers to two or 2 decimal places example using JavaScript toFixed() or toPrecision() functions or jQuery round off number with two or more decimal values using JavaScript toFixed() or toPrecision() functions.
Description:
In previous articles I explained jQuery upload images without postback using handler file, JavaScript get whole number division using Math.ceil function, JavaScript limit number characters in multiline textbox, jQuery fixed header on window scroll with example, jQuery currency conversion as per exchange rates and many articles relating to AngularJS, jQuery, JavaScript and asp.net. Now I will explain how to round off numbers to two or 2 decimal places example using JavaScript toFixed() or toPrecision() functions in jQuery.
In previous articles I explained jQuery upload images without postback using handler file, JavaScript get whole number division using Math.ceil function, JavaScript limit number characters in multiline textbox, jQuery fixed header on window scroll with example, jQuery currency conversion as per exchange rates and many articles relating to AngularJS, jQuery, JavaScript and asp.net. Now I will explain how to round off numbers to two or 2 decimal places example using JavaScript toFixed() or toPrecision() functions in jQuery.
By using toFixed() or toPrecision()
JavaScript function we can round off (roundup or rounddown)
numbers with decimal values using jQuery
like as shown below
toFixed() function will maintain
specified number of decimals
|
toPrecision() function will
format number to specified length
|
If
you want to check it in complete example you need to write the code like as
shown below
|
Live
Demo
For
live demo enter number with decimal value in below textbox and click button to
round off numbers using toFixed() and toPrecision() functions
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
0 comments :
Note: Only a member of this blog may post a comment.