把 times=new Date()放到函数里面时间正常走,放函数外面时间静止什么原因?
var atime;
var times=new Date();
function clock(){
atime=times.getHours()+"时"+times.getMinutes()+"分"+times.getSeconds()+"秒";
document.getElementById('time').value=atime;
}
setInterval(clock,100);
var atime;
var times=new Date();
function clock(){
atime=times.getHours()+"时"+times.getMinutes()+"分"+times.getSeconds()+"秒";
document.getElementById('time').value=atime;
}
setInterval(clock,100);
2016-08-12
举报