回答編集履歴
3
調整
test
CHANGED
@@ -50,7 +50,7 @@
|
|
50
50
|
|
51
51
|
```
|
52
52
|
|
53
|
-
# 調整
|
53
|
+
# 再調整
|
54
54
|
|
55
55
|
```javascript
|
56
56
|
|
@@ -60,19 +60,27 @@
|
|
60
60
|
|
61
61
|
var timerId;
|
62
62
|
|
63
|
-
var count=10;
|
64
|
-
|
65
63
|
var countdown;
|
66
64
|
|
67
65
|
document.querySelector('#start').addEventListener('click',e=>{
|
68
66
|
|
67
|
+
var count=100;
|
68
|
+
|
69
69
|
e.target.disabled=true;
|
70
70
|
|
71
|
-
document.querySelector('#txt')
|
71
|
+
with(document.querySelector('#txt')){
|
72
|
+
|
73
|
+
disabled=false;
|
74
|
+
|
75
|
+
value="";
|
76
|
+
|
77
|
+
focus();
|
78
|
+
|
79
|
+
}
|
72
80
|
|
73
81
|
timerId=setInterval(countdown=()=>{
|
74
82
|
|
75
|
-
document.querySelector('#timer').value=count;
|
83
|
+
document.querySelector('#timer').value=(count%10==0)?(count/10+".0"):count/10;
|
76
84
|
|
77
85
|
if(count<=0){
|
78
86
|
|
@@ -80,13 +88,15 @@
|
|
80
88
|
|
81
89
|
e.target.disabled=false;
|
82
90
|
|
91
|
+
document.querySelector('#txt').disabled=true;
|
92
|
+
|
83
93
|
}
|
84
94
|
|
85
95
|
count--;
|
86
96
|
|
87
97
|
return countdown;
|
88
98
|
|
89
|
-
},100
|
99
|
+
},100);
|
90
100
|
|
91
101
|
});
|
92
102
|
|
@@ -97,6 +107,8 @@
|
|
97
107
|
clearInterval(timerId);
|
98
108
|
|
99
109
|
document.querySelector('#start').disabled=false;
|
110
|
+
|
111
|
+
e.target.disabled=true;
|
100
112
|
|
101
113
|
alert('good!');
|
102
114
|
|
@@ -110,8 +122,8 @@
|
|
110
122
|
|
111
123
|
<input type="button" id="start" value="start">
|
112
124
|
|
113
|
-
<input type="text" id="txt">(abcと入力)
|
125
|
+
<input type="text" id="txt" disabled>(abcと入力)
|
114
126
|
|
115
|
-
<input type="text" id="timer">
|
127
|
+
<input type="text" id="timer" readonly>
|
116
128
|
|
117
129
|
```
|
2
start
test
CHANGED
@@ -49,3 +49,69 @@
|
|
49
49
|
<input type="text" id="timer">
|
50
50
|
|
51
51
|
```
|
52
|
+
|
53
|
+
# 調整
|
54
|
+
|
55
|
+
```javascript
|
56
|
+
|
57
|
+
<script>
|
58
|
+
|
59
|
+
window.addEventListener('DOMContentLoaded', ()=>{
|
60
|
+
|
61
|
+
var timerId;
|
62
|
+
|
63
|
+
var count=10;
|
64
|
+
|
65
|
+
var countdown;
|
66
|
+
|
67
|
+
document.querySelector('#start').addEventListener('click',e=>{
|
68
|
+
|
69
|
+
e.target.disabled=true;
|
70
|
+
|
71
|
+
document.querySelector('#txt').value="";
|
72
|
+
|
73
|
+
timerId=setInterval(countdown=()=>{
|
74
|
+
|
75
|
+
document.querySelector('#timer').value=count;
|
76
|
+
|
77
|
+
if(count<=0){
|
78
|
+
|
79
|
+
clearInterval(timerId);
|
80
|
+
|
81
|
+
e.target.disabled=false;
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
count--;
|
86
|
+
|
87
|
+
return countdown;
|
88
|
+
|
89
|
+
},1000);
|
90
|
+
|
91
|
+
});
|
92
|
+
|
93
|
+
document.querySelector('#txt').addEventListener('input',e=>{
|
94
|
+
|
95
|
+
if(e.target.value=="abc"){
|
96
|
+
|
97
|
+
clearInterval(timerId);
|
98
|
+
|
99
|
+
document.querySelector('#start').disabled=false;
|
100
|
+
|
101
|
+
alert('good!');
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
});
|
106
|
+
|
107
|
+
});
|
108
|
+
|
109
|
+
</script>
|
110
|
+
|
111
|
+
<input type="button" id="start" value="start">
|
112
|
+
|
113
|
+
<input type="text" id="txt">(abcと入力)
|
114
|
+
|
115
|
+
<input type="text" id="timer">
|
116
|
+
|
117
|
+
```
|
1
調整
test
CHANGED
@@ -3,3 +3,49 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
は基本的に非同期処理なので、文字入力の正誤判定と競合しないはずです
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
# sample
|
10
|
+
|
11
|
+
```javascript
|
12
|
+
|
13
|
+
<script>
|
14
|
+
|
15
|
+
window.addEventListener('DOMContentLoaded', ()=>{
|
16
|
+
|
17
|
+
document.querySelector('#txt').addEventListener('input',e=>{
|
18
|
+
|
19
|
+
if(e.target.value=="abc"){
|
20
|
+
|
21
|
+
clearInterval(timerId);
|
22
|
+
|
23
|
+
alert('good!');
|
24
|
+
|
25
|
+
}
|
26
|
+
|
27
|
+
});
|
28
|
+
|
29
|
+
var count=10;
|
30
|
+
|
31
|
+
var timerId=setInterval(countdown=()=>{
|
32
|
+
|
33
|
+
document.querySelector('#timer').value=count;
|
34
|
+
|
35
|
+
if(count<=0) clearInterval(timerId);
|
36
|
+
|
37
|
+
count--;
|
38
|
+
|
39
|
+
return countdown;
|
40
|
+
|
41
|
+
},1000);
|
42
|
+
|
43
|
+
});
|
44
|
+
|
45
|
+
</script>
|
46
|
+
|
47
|
+
<input type="text" id="txt">(abcと入力)
|
48
|
+
|
49
|
+
<input type="text" id="timer">
|
50
|
+
|
51
|
+
```
|