質問編集履歴

3

2020/07/31 12:43

投稿

momomomon
momomomon

スコア13

test CHANGED
File without changes
test CHANGED
@@ -12,28 +12,6 @@
12
12
 
13
13
 
14
14
 
15
- <p class="q-body">
16
-
17
-   <input id="q6-1" type="text" size="4"></input>
18
-
19
-  <select id="op6">
20
-
21
- <option>+</option>
22
-
23
- <option>‐</option>
24
-
25
- <option>×</option>
26
-
27
- <option>÷</option>
28
-
29
- <input id="q6-2" type="text" size="4"></input>
30
-
31
- <button id="q6-btn">計算</button><br>
32
-
33
- 計算結果:<span id="q6result"></span>
34
-
35
- </p>
36
-
37
15
 
38
16
 
39
17
  ```
@@ -44,40 +22,6 @@
44
22
 
45
23
 
46
24
 
47
- var btn6 = document.getElementById("q6-btn");
48
-
49
- var elm6 = document.getElementById("q6result");
50
-
51
- btn6.onclick = click6;
52
-
53
- function click6(){
54
-
55
-     var input6_left = document.getElementById("q6-1").value;
56
-
57
-     var select = document.getElementById("op6");
58
-
59
-     var input6_right = document.getElementById("q6-2").value;
60
-
61
-      if(Number(select) === +){
62
-
63
-         elm5.textContent = Number(input6_left) + Number(input6_right);
64
-
65
-      } else if(Number(select) === -){
66
-
67
-         elm5.textContent = Number(input6_left) - Number(input6_right);
68
-
69
-      } else if(Number(select) === *){
70
-
71
-         elm5.textContent = Number(input6_left) * Number(input6_right);
72
-
73
-      } else {
74
-
75
-         elm5.textContent = Number(input6_left) / Number(input6_right);
76
-
77
-       }
78
-
79
- }
80
-
81
25
 
82
26
 
83
27
  ```

2

2020/07/31 12:43

投稿

momomomon
momomomon

スコア13

test CHANGED
File without changes
test CHANGED
@@ -66,7 +66,7 @@
66
66
 
67
67
          elm5.textContent = Number(input6_left) - Number(input6_right);
68
68
 
69
-      } else if(Number(select) === /){
69
+      } else if(Number(select) === *){
70
70
 
71
71
          elm5.textContent = Number(input6_left) * Number(input6_right);
72
72
 

1

2020/07/30 22:03

投稿

momomomon
momomomon

スコア13

test CHANGED
File without changes
test CHANGED
@@ -44,19 +44,19 @@
44
44
 
45
45
 
46
46
 
47
- var btn6 = document.getElementById("q6-btn");// "q6-btn"のDOM要素の取得
47
+ var btn6 = document.getElementById("q6-btn");
48
48
 
49
- var elm6 = document.getElementById("q6result");// "q6result"のDOM要素の取得
49
+ var elm6 = document.getElementById("q6result");
50
50
 
51
- btn6.onclick = click6; // btn6のonclickプロパティにイベントハンドラを設定
51
+ btn6.onclick = click6;
52
52
 
53
- function click6(){ //イベントハンドラ(関数)を定義
53
+ function click6(){
54
54
 
55
-     var input6_left = document.getElementById("q6-1").value; //"q6-1"のDOM要素の取得
55
+     var input6_left = document.getElementById("q6-1").value;
56
56
 
57
57
      var select = document.getElementById("op6");
58
58
 
59
-     var input6_right = document.getElementById("q6-2").value; //"q6-2"のDOM要素の取得
59
+     var input6_right = document.getElementById("q6-2").value;
60
60
 
61
61
       if(Number(select) === +){
62
62