1.只取小数点后两位:
<script>
alert(("156782.1234").replace(/^(.*\..{2}).*$/,"$1"));
</script>
2.取小数点后的位数:
<script>
alert(("156782.12346").replace(/(\d*\.?)/,"").length);
</script>
3.只取小数点后两位,四舍五入:
<script>
alert(3.1415926.toFixed(3));
</script>
---------------------------------------------------------------------------------------------------------------------------------
说人之短,乃护己之短。夸己之长,乃忌人之长。皆由存心不厚,识量太狭耳。能去此弊,可以进德,可以远怨。
http://www.blogjava.net/szhswl
------------------------------------------------------------------------------------------------------ ----------------- ---------
posted on 2007-12-06 10:53
宋针还 阅读(2944)
评论(0) 编辑 收藏 所属分类:
JAVASCRIPT