用JavaScript语言设计程序:在一个input框中显示当前的年.月.日,当鼠标放上去时就变换为当前的时间显示.
1个回答
展开全部
不知道是不是你说的意思。 <html> <body> <script type="text/javascript"> var times = ""; function tick() { var year, month, date, week; var hours, minutes, seconds; var today = new Date(); year = today.getYear(); month = today.getMonth()+1; date = today.getDate(); hours = today.getHours(); minutes = today.getMinutes(); seconds = today.getSeconds(); if(today.getDay()==0) week="星期日"; if(today.getDay()==1) week="星期一"; if(today.getDay()==2) week="星期二"; if(today.getDay()==3) week="星期三"; if(today.getDay()==4) week="星期四"; if(today.getDay()==5) week="星期五"; if(today.getDay()==6) week="星期六"; if(month < 10){ month = "0"+month; } if(date < 10){ date = "0"+date; } if(hours < 10){ hours = "0"+hours; } if(minutes < 10){ minutes = "0"+minutes; } if(seconds < 10){ seconds = "0"+seconds; } document.getElementById("inday").value = year+"年"+month+"月"+date+"日"+week; times = hours+"点"+minutes+"分"+seconds+"秒"; } window.onload = tick; function getTimes() { document.getElementById("inday").value = times; } </script> <input type="text" id="inday" value="" onmouseover="getTimes()" onmouseout="tick()" size="20" /> </body> </html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询