问答详情
源自:7-16 随机数 random()

请问这样怎么不行呢?

<!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>


提问者:慕慕8881611 2017-09-12 19:00

个回答

  • 慕慕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>