编辑下面的代码:【加编码】
<html> <body> <p id="demo">Click the button to round the number 1.6 downward to it's nearest integer.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var a=Math.floor(0.60); var b=Math.floor(0.40); var c=Math.floor(5); var d=Math.floor(5.1); var e=Math.floor(-5.1); var f=Math.floor(-5.9); var x=document.getElementById("demo"); x.innerHTML=a + "<br>" + b + "<br>" + c + "<br>" + d + "<br>" + e + "<br>" + f; } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂