我想打印时间时把之前打印的时间的清掉,只让他打印一次,求解
var str = "" function getTime(){ document.write(str) var data = new Date() var year = data.getFullYear() var mon = data.getMonth() var day = data.getDate() var hour = data.getHours() var min = data.getMinutes() var sec = data.getSeconds() str = year+"年"+mon+"月"+day+"日"+hour+"时"+min+"分"+sec+"秒" document.write(str) } getTime()
setInterval(getTime,1000)
akakidz
慕斯4360584
相关分类