亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么setTimeout(0不能支持1000mm以下的時間呀?還是我的程序有問題?幫我看看是怎么了

為什么setTimeout(0不能支持1000mm以下的時間呀?還是我的程序有問題?幫我看看是怎么了

慕森卡 2022-11-20 22:18:28
<title>秒表</title><script language="javascript">function showing(){// showFast();setInterval("showTime()",1000);}function showTime() //每一秒刷新一次  {mytime=new Date(); //創造一個時間對象比獲得他的時間元素year=mytime.getYear();date=mytime.getDate();month=mytime.getMonth();day=mytime.getDay();hours=mytime.getHours();minutes=mytime.getMinutes();seconds=mytime.getSeconds();temp="上午好";Astr=new String("");formatTime(hours.minutes,seconds);Astr+=("<font size='+1' color='red'>"+year+"年"+month+"月"+date+"日"+"星期"+(day+1)+"</font>");document.getElementById("lay3").innerHTML=Astr;Bstr="<font size='+1' color='red'>"+temp+hours+":"+minutes+":"+seconds+"</font>";document.getElementById("lay1").innerHTML=Bstr;for(s=0;s<100;++s) //從00到99循環{setTimeout("",10);document.getElementById("lay2").innerText=s;// if(s<10) s="0"+s;// setTimeout("showI(s)",10);// if(s=99)s=0;}}function showI(s){document.getElementById("lay2").innerText=s;}function formatTime(){if(hours!=0&&hours<=7) //決定問候語temp="早上好";else if(hours>7&&hours<11)temp="上午好";else if(hours>=11&&hours<13)temp="中午好";else if(hours>=13&&hours<=18)temp="下午好";else if(hours>18&&hours<24)temp="晚上好";  if(hours<=9)hours="0"+hours; //格式化時間使之以兩位數的格式顯示if(minutes<=9)minutes="0"+minutes;if(seconds<=9)seconds="0"+seconds;  }  /*function showFast(){for(s=0;s<100;s++){if(s<10) s="0"+s;setTimeout("showI(s)",10);// if(s=99)s=0;}} */</script> <style type="text/css"><!--#lay3 {position:absolute;left:367px;top:134px;width:246px;height:42px;}#Lay1 {position:absolute;left:368px;top:178px;width:182px;height:38px;}#lay2 {position:absolute;left:552px;top:178px;width:63px;height:39px;}--></style></head ><body onload="showing()"><span id="lay3"></span><span id="Lay1"></span><span id="lay2"></span></body></html>
查看完整描述

1 回答

?
海綿寶寶撒

TA貢獻1809條經驗 獲得超8個贊

可憐的孩子...辛苦你了, 寫了這么一大篇, 為了實現一個數字時鐘的功能...這讓我想起了我小時候...
你的錯誤就在于:
<span id="Lay1"></span>及
document.getElementById("lay1")
發現沒有啊, 粗心的孩子, lay1兩處大小寫不一致呵...

查看完整回答
反對 回復 2022-11-24
  • 1 回答
  • 0 關注
  • 78 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號