JavaScriptのエラー
###質問内容
こんばんは。初めての投稿です。
IpadのTextastic というものを使ってプログラミングの勉強をしています。
ユーチューブの動画を参考にしながらクイズゲームの作成に取り掛かっているのですが、下記のエラーが発生し、ユーチューブの人のような表記がされません。
ググったりしているのですが、なにぶん初心者なのでわからない事も多くお手上げ状態です。
どこが間違っているのか、どのようにすれば良くなるか教えていただきたいです。
発生している問題・エラーメッセージ
error
1TypeError: document.getElementsById is not a function. (In 'document.getElementsById('js-question')', 'document.getElementsById' is undefined)
###ソースコード
html
1 2<!doctype html> 3<html class="no-js" lang=""> 4 5<head> 6 <meta charset="utf-8"> 7 <title></title> 8 <meta name="description" content=""> 9 <meta name="viewport" content="width=device-width, initial-scale=1"> 10 11 <meta property="og:title" content=""> 12 <meta property="og:type" content=""> 13 <meta property="og:url" content=""> 14 <meta property="og:image" content=""> 15 16 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> 17 18 19 <link rel="stylesheet" href="css/normalize.css"> 20 <link rel="stylesheet" href="css/main.css"> 21 22 <meta name="theme-color" content="#fafafa"> 23</head> 24 25<body> 26 <div class="container"> 27 <div id="js-question" class="alert alert-info" role="alert"> 28 A simple info alert—check it out! 29 </div> 30 <div class="d-flex justify-content-center"> 31 <button type="button" class="btn btn-primary">Primary</button> 32 <button type="button" class="ms-1 btn btn-primary">Primary</button> 33 <button type="button" class="ms-1 btn btn-primary">Primary</button> 34 <button type="button" class="ms-1 btn btn-primary">Primary</button> 35 </div> 36 </div> 37 <script src="app.js"></script> 38</body> 39 40</html>
JavaScript
1 const question = "#"; 2 3const answers = [ 4"","#","#","#" 5]; 6const correct = "#"; 7document.getElementsById('js-question').textContent = 'question';
試したこと
Constの最後の「question」を消してみたり、””を’’にしてみたり、自身でできるようなことはしたつもりです…
至らないところがありすみませんが、わかる方はお願いします。
補足情報(FW/ツールのバージョンなど)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。