请问这样怎么不行呢?

来源:7-16 随机数 random()

慕慕8881611

2017-09-12 19:00

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Math </title>

<script type="text/javascript">

var ran=Math.random()*10;

document.write(ran.round());

</script>

</head>

<body>

</body>

</html>


写回答 关注

2回答

  • 慕慕8881611
    2017-09-12 19:15:24

    大功告成、!

    <!DOCTYPE html>

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>Math </title>

    <script type="text/javascript">

    document.write(Math.round(parseInt(Math.random()*10)));

    </script>

    </head>

    <body>

    </body>

    </html>


  • 慕慕8881611
    2017-09-12 19:13:02


    这样也不行呀、

    <!DOCTYPE html>

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>Math </title>

    <script type="text/javascript">

    document.write((Math.random()*10).round());

    </script>

    </head>

    <body>

    </body>

    </html>


JavaScript进阶篇

本课程从如何插入JS代码开始,带您进入网页动态交互世界

468061 学习 · 21891 问题

查看课程

相似问题