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

为什么这样点击刷新按钮后随机数会出现,但按钮不见了?

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Math </title>

</head>
<body>
    
        <input name="hah" type="button"  value="刷新"  onclick="newNum()"/>
        <script type="text/javascript">
    function newNum(){
        document.write(Math.random());
        
    }
</script>
   
</body>
</html>


提问者:狮子追求真理 2016-04-05 23:41

个回答

  • qq_物是人非事事休_0
    2016-04-14 21:28:16

    将 “documen.write”换成“alert”或者“confim”代码就ok了

  • 冯冬冬
    2016-04-06 00:07:50

    document.write(document.body.innerHTML);前面加上一句这个。document.write重写了界面,会将原来的全部覆盖掉