javascriptでカウントダウンタイマーの作り方を解説しているサイトリンク内容https://dev83.com/js-countdown/
で書かれてあるコードをVScode写経しながらjavascriptのカウントダウンタイマーを作成して
Microsoftedgeで開いたらなぜかタイマーが表示されてなく,
Microsoftedgeの開発者ツールを開きバグなどがないか確認したところUncaught TypeError: document.getElementByid is timer.html:25 not a function
at HTMLDocument.<anonymous> (timer.html:25:36)
と出てきてしまい解決方法がわからず困っています
詳しい解決方法教えてくれませんか?
長文失礼しました
↓
html ```<!DOCTYPE html> <html> <body> <div class="timer" id="timer"></div> <style> .timer{ font-weight:bold; font-size :1.6em; color:#222; } </style> <script> document.addEventListener('DOMContentLoaded', function() { var Timer=function(saleStartTime,saleEndtime,endmessage,outputDestination){ this.saleStartTime=saleStartTime; this.saleEndtime=saleEndtime; this.endmessage=endmessage; this.outputDestination=outputDestination; }; Timer.prototype.countDown=function(){} var saleStarttime=new Date(this.saleStartTime); var saleEndtime=new Date(this.saleEndtime); var countDownTime=document.getElementById(this.outputDestination) var endMEssage=this.endMEssage; var currenttimeCD; var currentTime; var untilStartTime; var untilFinishtime; var oneDay=24*60*60*1000; var d=0; var h=0; var m=0; var s=0; function calculateTime(){ currentTimeCD=newDate(); untilStartTime=saleStartTime-currentTimeCD; untilFinishtime=saleEndTime-currentTimeCD; if(currentTimeCD<saleStartTime){ D=Math.floor(untilStartTime/oneDay); h=math.floor((untilStartTime%oneDay)/(60*60*1000)); m=Math.floor((untilStartTime%oneDay)/(60*1000))%60; s=Math.floor((untilStartTime%oneDay)/1000)%60%60; }else{ d=Math.floor(untilFinishtime/oneDay) h=Math.floor((untilfinishTime%oneDay)/(60*60*1000))%60; m=Math.floor((untilFinishTime%oneDay)/(60*1000))%60; s=Math.floor((untilFinishTime%oneDay)/1000)%60%60; } showTime(); } function ShowTime(){ if(currentTimeCD<saleStartTime){ counDownTimer.innerHTML ='開始まで'+d+'日'+h+'時間'+m+分+s+'秒'; }else if(currentTimeCD>=saleStartTime &¤tTimeCD<=saleEndTime){ cuntDownTimer.innerHTML ='あと'+d+'日'+h+'時間'+m+'分'+s+'秒'+'で終了'; }else{ countDownTimer.innerHTML=endMessage; } } setInterval(calculateTime,1000); var myTimer=new Timer('2022/01/23 00:00:00', '2022/1/24 00:00:00', '終了!','timer'); myTimer.countDown(); },false) </script> </body> </html>

回答2件
あなたの回答
tips
プレビュー