teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

6

2021/01/06 15:10

投稿

tora822
tora822

スコア0

title CHANGED
File without changes
body CHANGED
@@ -102,4 +102,7 @@
102
102
 
103
103
  ここにより詳細な情報を記載してください。
104
104
  この動画を参考にしました。
105
- https://www.youtube.com/watch?v=fAluwAmHrws&t=311s
105
+ https://www.youtube.com/watch?v=fAluwAmHrws&t=311s
106
+
107
+ jaのelse文以前までは反映がされ、
108
+ 以降は記入時も無記入時も反映がされていません。

5

2021/01/06 15:10

投稿

tora822
tora822

スコア0

title CHANGED
File without changes
body CHANGED
@@ -1,6 +1,6 @@
1
1
  ### 前提・実現したいこと
2
2
  正誤ゲームで、不正解のアラートを出したい
3
- ここに質問の内容を詳しく書いてください。
3
+
4
4
  Javascriptで、Youtubeの解説を見ながら、if文、else文を用いて簡単な4択のクイズゲームを作成しようとしていました。その際、正解のボタンをクリックすると正常にアラートが出るのですが、不正解のボタンを押しても反映されず、consoleに以下のようなエラーが出ました。
5
5
 
6
6
  ### 発生している問題・エラーメッセージ

4

回答指摘の該当欄の削除

2021/01/06 15:09

投稿

tora822
tora822

スコア0

title CHANGED
File without changes
body CHANGED
@@ -54,7 +54,6 @@
54
54
  <meta property="og:url" content="">
55
55
  <meta property="og:image" content="">
56
56
 
57
- <link rel="manifest" href="site.webmanifest">
58
57
  <link rel="apple-touch-icon" href="icon.png">
59
58
  <!-- Place favicon.ico in the root directory -->
60
59
 

3

window.alert("不正解!")の閉じタグを追加 効果はなし

2021/01/06 11:34

投稿

tora822
tora822

スコア0

title CHANGED
File without changes
body CHANGED
@@ -34,7 +34,7 @@
34
34
  if (correct === document.getElementsByTagName("button")[1].textContent){
35
35
  window.alert("正解!");
36
36
  }else{
37
- window.alert("不正解!")
37
+ window.alert("不正解!");
38
38
  }
39
39
  });
40
40
 

2

HTMLのソースコードを追記した

2021/01/06 11:15

投稿

tora822
tora822

スコア0

title CHANGED
File without changes
body CHANGED
@@ -38,6 +38,64 @@
38
38
  }
39
39
  });
40
40
 
41
+
42
+ HTML
43
+ <!doctype html>
44
+ <html class="no-js" lang="">
45
+
46
+ <head>
47
+ <meta charset="utf-8">
48
+ <title></title>
49
+ <meta name="description" content="">
50
+ <meta name="viewport" content="width=device-width, initial-scale=1">
51
+
52
+ <meta property="og:title" content="">
53
+ <meta property="og:type" content="">
54
+ <meta property="og:url" content="">
55
+ <meta property="og:image" content="">
56
+
57
+ <link rel="manifest" href="site.webmanifest">
58
+ <link rel="apple-touch-icon" href="icon.png">
59
+ <!-- Place favicon.ico in the root directory -->
60
+
61
+ <!-- CSS only -->
62
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
63
+
64
+ <meta name="theme-color" content="#fafafa">
65
+ </head>
66
+
67
+ <body>
68
+ <div class="container">
69
+
70
+ <div class="jumbotron mt-5">
71
+ <div class="d-flex justify-content-center">
72
+ <div id="js-question" class="alert alert-primary" role="alert">
73
+ A simple primary alert—check it out!
74
+ </div>
75
+ </div>
76
+
77
+ <div id="js-items" class="d-flex justify-content-center">
78
+ <div class="m-2">
79
+ <button type="button" id="js-btn-1" class="btn btn-primary">Primary</button>
80
+ </div>
81
+ <div class="m-2">
82
+ <button type="button" id="js-btn-2" class="btn btn-primary">Primary</button>
83
+ </div>
84
+ <div class="m-2">
85
+ <button type="button" id="js-btn-3" class="btn btn-primary">Primary</button>
86
+ </div>
87
+ <div class="m-2">
88
+ <button type="button" id="js-btn-4" class="btn btn-primary">Primary</button>
89
+ </div>
90
+ </div>
91
+ </div>
92
+ </div>
93
+
94
+ <script src="app.js"></script>
95
+ </body>
96
+
97
+ </html>
98
+
41
99
  ### 試したこと
42
100
  スペルミスのチェック、CORSとは何かを検索
43
101
 

1

参照した動画のURLを追加

2021/01/06 11:11

投稿

tora822
tora822

スコア0

title CHANGED
File without changes
body CHANGED
@@ -43,4 +43,6 @@
43
43
 
44
44
  ### 補足情報(FW/ツールのバージョンなど)
45
45
 
46
- ここにより詳細な情報を記載してください。
46
+ ここにより詳細な情報を記載してください。
47
+ この動画を参考にしました。
48
+ https://www.youtube.com/watch?v=fAluwAmHrws&t=311s