日期:2014-05-16  浏览次数:20334 次

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

------解决方案--------------------
HTML code

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