HTML代码如下:代码1:functionshowTime(){vartoday=newDate();varhou=today.getHours();varmin=today.getMinutes();varsec=today.getSeconds();document.getElementsByName('time')[0].value=hou+':'+min+''+sec;}setInterval(showTime,1000);代码2:functionshowTime(){vartoday=newDate();varhou=today.getHours();varmin=today.getMinutes();varsec=today.getSeconds();document.getElementsByName('time')[0].value=hou+':'+min+''+sec;}showTime();代码2在html中不显示我理解,从上到下执行,input没加载,不执行正常,但代码1多了个setInterval怎么就可以执行了呢?input不是没载入吗?
jeck猫
相关分类