JavaScript round() 方法【每日一段代码95】
2012-04-24 21:44
736 查看
<html>
<body>
<script type="text/javascript">
document.write(Math.round(0.60)+"<br />");
document.write(Math.round(0.50)+"<br />");
document.write(Math.round(0.49)+"<br />");
document.write(Math.round(-4.50)+"<br />");
document.write(Math.round(-4.60));
</script>
</body>
</html>
【round() 方法可把一个数字舍入为最接近的整数。】
<body>
<script type="text/javascript">
document.write(Math.round(0.60)+"<br />");
document.write(Math.round(0.50)+"<br />");
document.write(Math.round(0.49)+"<br />");
document.write(Math.round(-4.50)+"<br />");
document.write(Math.round(-4.60));
</script>
</body>
</html>
【round() 方法可把一个数字舍入为最接近的整数。】
相关文章推荐
- JavaScript getTime()方法 【每日一段代码84】
- JavaScript random() 方法【每日一段代码96】
- JavaScript match()方法 【每日一段代码82】
- JavaScript toUTCString() 方法 【每日一段代码86】
- JavaScript indexOf() 方法 【每日一段代码81】
- JavaScript sort() 方法数组排序文字【每日一段代码92】
- JavaScript join() 方法【每日一段代码91】
- JavaScript setFullYear()方法 【每日一段代码85】
- JavaScript getDay() 方法 【每日一段代码87】
- JavaScript sort() 方法数组排序数字【每日一段代码93】
- Javascript 变量赋值 【每日一段代码40】
- JavaScript concat() 连接数组【每日一段代码90】
- JavaScript 确认检测浏览器及版本【每日一段代码65】
- JavaScript boolean 对象检查逻辑值【每日一段代码94】
- JavaScript 提示按钮 【每日一段代码49】
- JavaScript 按钮动画【每日一段代码70】
- JavaScript for 循环【每日一段代码55】
- JavaScript 练习 生成文字 【每日一段代码36】
- JavaScript 计时器2 【每日一段代码73】
- JavaScript for 循环标题【每日一段代码56】