运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h2>JavaScript Number Methods</h2> <p>The toFixed() method rounds a number to a given number of digits.</p> <p>For working with money, toFixed(2) is perfect.</p> <p id="demo"></p> <script> let x = 9.656; document.getElementById("demo").innerHTML = x.toFixed(0) + "<br>" + x.toFixed(2) + "<br>" + x.toFixed(4) + "<br>" + x.toFixed(6); </script> </body> </html>