编辑下面的代码:【加编码】
<html> <body> <p id="demo">Click the button to the absolute value of different numbers</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var a=Math.abs(7.25); var b=Math.abs(-7.25); var c=Math.abs(null); var d=Math.abs("Hello"); var e=Math.abs(2+3); var x=document.getElementById("demo"); x.innerHTML=a + "<br>" + b + "<br>" + c + "<br>" + d + "<br>" + e; } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂