質問編集履歴
3
いろいろと変更して試してみました。ブラウザにもコンソールにも計算結果は出力されるのですが、毎秒更新されません。
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,15 +24,21 @@
|
|
24
24
|
|
25
25
|
```
|
26
26
|
|
27
|
-
|
27
|
+
1776日 00時間 17分 23秒
|
28
28
|
|
29
|
-
|
29
|
+
question.js:26 Uncaught TypeError: Cannot read property '0' of undefined
|
30
30
|
|
31
|
-
at question.js:
|
31
|
+
at recalc (question.js:26)
|
32
32
|
|
33
|
-
recalc @ question.js:2
|
33
|
+
recalc @ question.js:26
|
34
34
|
|
35
|
+
setTimeout (async)
|
36
|
+
|
37
|
+
refresh @ question.js:34
|
38
|
+
|
39
|
+
recalc @ question.js:30
|
40
|
+
|
35
|
-
(anonymous) @ question.js:3
|
41
|
+
(anonymous) @ question.js:3
|
36
42
|
|
37
43
|
```
|
38
44
|
|
@@ -96,11 +102,11 @@
|
|
96
102
|
|
97
103
|
function recalc(counter, getid) {
|
98
104
|
|
99
|
-
const timer
|
105
|
+
const timer = `${counter[0]}日 ${counter[1]}時間 ${counter[2]}分 ${counter[3]}秒`;
|
100
106
|
|
101
|
-
console.log(timer
|
107
|
+
console.log(timer);
|
102
108
|
|
103
|
-
document.getElementById(getid).textContent = timer
|
109
|
+
document.getElementById(getid).textContent = timer;
|
104
110
|
|
105
111
|
|
106
112
|
|
@@ -116,7 +122,11 @@
|
|
116
122
|
|
117
123
|
}
|
118
124
|
|
125
|
+
|
126
|
+
|
127
|
+
const osakaId = 'countdownOsaka';
|
128
|
+
|
119
|
-
recalc(osakaCounter,
|
129
|
+
recalc(osakaCounter, osakaId);
|
120
130
|
|
121
131
|
```
|
122
132
|
|
2
ソースコードを貼り間違えていたため、訂正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,15 +24,15 @@
|
|
24
24
|
|
25
25
|
```
|
26
26
|
|
27
|
-
question.js:
|
27
|
+
question.js:28 Uncaught TypeError: Cannot set property 'textContent' of null
|
28
28
|
|
29
|
-
at recalc (question.js:
|
29
|
+
at recalc (question.js:28)
|
30
30
|
|
31
|
-
at question.js:
|
31
|
+
at question.js:36
|
32
32
|
|
33
|
-
recalc @ question.js:
|
33
|
+
recalc @ question.js:28
|
34
34
|
|
35
|
-
(anonymous) @ question.js:
|
35
|
+
(anonymous) @ question.js:36
|
36
36
|
|
37
37
|
```
|
38
38
|
|
@@ -86,19 +86,7 @@
|
|
86
86
|
|
87
87
|
|
88
88
|
|
89
|
-
let osakaGoal = new Date();
|
89
|
+
let osakaGoal = new Date(2025, 4, 13, 0, 0, 0);
|
90
|
-
|
91
|
-
osakaGoal.setFullYear(2025);
|
92
|
-
|
93
|
-
osakaGoal.setMonth(4);
|
94
|
-
|
95
|
-
osakaGoal.setDate(13);
|
96
|
-
|
97
|
-
osakaGoal.setHours(0);
|
98
|
-
|
99
|
-
osakaGoal.setMinutes(0);
|
100
|
-
|
101
|
-
osakaGoal.setSeconds(0);
|
102
90
|
|
103
91
|
|
104
92
|
|
@@ -108,15 +96,11 @@
|
|
108
96
|
|
109
97
|
function recalc(counter, getid) {
|
110
98
|
|
111
|
-
const counterX = counter;
|
112
|
-
|
113
|
-
const timerX = `${counter
|
99
|
+
const timerX = `${counter[0]}日 ${counter[1]}時間 ${counter[2]}分 ${counter[3]}秒`;
|
114
|
-
|
115
|
-
const byId = document.getElementById(getid);
|
116
100
|
|
117
101
|
console.log(timerX);
|
118
102
|
|
119
|
-
|
103
|
+
document.getElementById(getid).textContent = timerX;
|
120
104
|
|
121
105
|
|
122
106
|
|
@@ -124,13 +108,13 @@
|
|
124
108
|
|
125
109
|
}
|
126
110
|
|
111
|
+
|
112
|
+
|
127
113
|
function refresh() {
|
128
114
|
|
129
115
|
setTimeout(recalc, 1000);
|
130
116
|
|
131
117
|
}
|
132
|
-
|
133
|
-
|
134
118
|
|
135
119
|
recalc(osakaCounter, countdownOsaka);
|
136
120
|
|
1
誤字を訂正しました。
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
パラメータをファンクション内のgetElementByIdに代入してsetTimeoutで繰り返し表示させたい
|
1
|
+
パラメータをファンクション内のgetElementByIdに代入してsetTimeoutで繰り返し表示させたいです。
|
test
CHANGED
File without changes
|