JavaScript实现实时更新系统时间的实例代码
一、Js代码
functiongetTime(){
str="当前系统时间:"
varp=document.getElementById("sy_time");
time=newDate();
year=time.getFullYear();
month=time.getMonth()+1;
day=time.getDate();
hour=time.getHours();
minutes=time.getMinutes();
seconds=time.getSeconds();
str=str+year+"-"+month+"-"+day+""+hour+":"+minutes+":"+seconds;
p.innerText=str;
setTimeout(getTime,1000);
}
window.onload=function(){
getTime();
}
二、前端代码
以上所述是小编给大家介绍的JavaScript实现实时更新系统时间的实例代码,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的,在此也非常感谢大家对毛票票网站的支持!
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短