Modern browsers must support a method called toFixed(). Here is an example taken from the Internet :
var num = 10;
var result = num.toFixed(2);
num = 930.9805;
result = num.toFixed(3);
toPrecision() may also be useful to you, there is another great example on this page.
For older browsers, you can execute it manually using Math.round. Math.round()rounded to the nearest integer. To achieve decimal precision, you need to manipulate your numbers a bit:
, 5.11111111 , :
var result=Math.round(5.111111*1000)/1000