显示时间的语句如下:
<script type=text/javascript>
document.write("<span id='labtime' width='120px' Font-Size='9pt'></span>")
setInterval("labtime.innerText=new Date().toLocaleString()",1000)
</script>
有错吗?为什么在这个时间在程序中无法显示?

解决方案 »

  1.   

    setInterval("function(){document.getElementById('labtime').innerText=new Date().toLocaleString()}",1000)
      

  2.   

    innerText   --》 innerHTML
      

  3.   


    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="gb2312" />
    <title></title>
    </head>
    <body>
    <script type=text/javascript>
    document.write("<span id='labtime' width='120px' Font-Size='9pt'></span>")
    setInterval(function(){document.getElementById('labtime').innerHTML=new Date().toLocaleString()},1000)
    </script> </body>
    </html>