问答详情
源自:8-3 计时器setInterval()

为什么不起作用

<html>
    <head>
        <script type="text/javascript">
            function clock(){
                var time=new Data;
                document.getElementById("ab").value=time;
           }
         var cd=setInterval("clock()",1000);
        </script>
    </head>
    <body>
        <form>
            <input type="text" id="ab"/>
        </form>
    </body>
</html>

提问者:慕丝3582901 2019-03-27 22:40

个回答

  • 伤口灬愈合
    2019-03-28 11:27:22
    已采纳

    data 改成Date();

  • 伤口灬愈合
    2019-03-28 11:26:37

    <html>
        <head>
            <script type="text/javascript">
                function clock(){
                    var time=new Date();
                    document.getElementById("ab").value=time;
               }
             var cd=setInterval("clock()",1000);
            </script>
        </head>
        <body>
            <form>
                <input type="text" id="ab"/>
            </form>
        </body>
    </html>