Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

simple way to make 3.2242143 to 3.2 using jquery

i have many data like this :

3.23214215

but i want to use the 3.2 part ,

what can i do using jquery ,

thanks

like image 691
zjm1126 Avatar asked Feb 17 '11 07:02

zjm1126


2 Answers

yourNumber.toFixed(1);

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number/toFixed

like image 162
Vadiklk Avatar answered Oct 06 '22 03:10

Vadiklk


You can use plain Javascript:

var n = 3.23214215
var fixed = n.toFixed(1)
like image 37
schneck Avatar answered Oct 06 '22 05:10

schneck