1、编辑html页面

 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>
Math对象

相关文章:

  • 2021-05-30
  • 2021-12-13
  • 2022-01-22
  • 2021-09-04
  • 2021-10-08
  • 2022-12-23
猜你喜欢
  • 2022-02-05
  • 2022-01-08
  • 2021-07-13
  • 2021-12-18
相关资源
相似解决方案