标签:
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 5 <title>Math对象的方法</title> 6 <script type="text/javascript"> 7 window.onload=function(){ 8 var str=Math.ceil(25.1)+"<br/>"; //上舍入,由小数点就进1 9 str+=Math.floor(26.5)+"<br/>"; //对数进行下舍入,由小数点就省略 10 str+=Math.round(25.5)+"<br/>"; //四舍五入 11 str+=Math.random()+"<br/>"; //随机数,0-1不包含0和1 12 document.getElementsByTagName("div")[0].innerHTML=str; 13 } 14 </script> 15 </head> 16 <body> 17 <div></div> 18 </body> 19 </html>
标签:
原文地址:http://www.cnblogs.com/holly8/p/5783389.html