Javascript
1btn.addEventListener('click', function(){ 2 if (!isStarted) { 3 isStarted = true; 4 startTime = Date.now(); 5 this.innerHTML = 'STOP'; 6 result.innerHTML = msg; 7 } else { 〜
ふと思ったのですが、例えば上記 clickがなされた際に、既述の現在時刻取得等に加え、
body{font-family:cursive;}
という内容でフォントの変更を盛り込むにはどのように記述するのでしょうか?
document.getElementByTagName("body").style.fontFamily = 'cursive';
または
document.getElementByName("body").style.fontFamily = 'cursive';
としても
get5seconds.html:62 Uncaught TypeError: document.getElementByName is not a function at HTMLDivElement.<anonymous>
または
get5seconds.html:62 Uncaught TypeError: document.getElementByName is not a function at HTMLDivElement.<anonymous>
とのエラーとなります。
検索しましたが解答を得るに至らずです。 (btnと bodyは別だから、body.addEvent〜などとやるのだろうか?そうなるとbtn.add〜とbody.addを同期させて。。。?)
ご教授いただけますと幸いです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。