开发者

simple way to make 3.2242143 to 3.2 using jquery

i ha开发者_JAVA百科ve many data like this :

3.23214215

but i want to use the 3.2 part ,

what can i do using jquery ,

thanks


yourNumber.toFixed(1);

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


You can use plain Javascript:

var n = 3.23214215
var fixed = n.toFixed(1)


You don't need jquery, plain old javascript does the trick:

var chopped = Math.floor(full_length * 10.0) / 10.0;


You can do it in plain old Javascript:

var f = 3.23214215;
f *= 10;
var i = parseInt(f);
f = i / 10;

You could also look into the Math object. There might be a rounding function in it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜