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实现实时更新系统时间的实例代码,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的,在此也非常感谢大家对毛票票网站的支持!