回答編集履歴
1
修正
test
CHANGED
@@ -2,26 +2,66 @@
|
|
2
2
|
|
3
3
|
とりあえず、これでどうですか?
|
4
4
|
|
5
|
-
```
|
5
|
+
```
|
6
6
|
|
7
|
-
|
7
|
+
<!DOCTYPE html>
|
8
8
|
|
9
|
-
|
9
|
+
<html>
|
10
10
|
|
11
|
-
|
11
|
+
<head>
|
12
12
|
|
13
|
-
|
13
|
+
<meta charset="UTF-8">
|
14
14
|
|
15
|
-
|
15
|
+
</head>
|
16
16
|
|
17
|
-
|
17
|
+
<body>
|
18
18
|
|
19
|
-
|
19
|
+
<form>
|
20
20
|
|
21
|
-
|
21
|
+
<input type="text" id="text_text">
|
22
22
|
|
23
|
-
|
23
|
+
<button type="button" id="button_button">値を入れる</button>
|
24
24
|
|
25
|
+
<button type="button" id="button_button2">今までで一番大きな値をだす</button>
|
26
|
+
|
27
|
+
</form>
|
28
|
+
|
29
|
+
<script>
|
30
|
+
|
31
|
+
var nums = [];
|
32
|
+
|
33
|
+
document.getElementById("button_button").addEventListener("click", function () {
|
34
|
+
|
35
|
+
if (Number.isInteger(parseInt(document.getElementById("text_text").value, 10))) {
|
36
|
+
|
37
|
+
nums.push(parseInt(document.getElementById("text_text").value, 10));
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
});
|
42
|
+
|
43
|
+
document.getElementById("button_button2").addEventListener("click", function () {
|
44
|
+
|
45
|
+
var Maxnum = 0;
|
46
|
+
|
47
|
+
for (var num = 0; num <= nums.length; num++) {
|
48
|
+
|
49
|
+
if (nums[num] > Maxnum) {
|
50
|
+
|
51
|
+
Maxnum = nums[num];
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
}
|
56
|
+
|
25
|
-
|
57
|
+
alert(Maxnum);
|
58
|
+
|
59
|
+
});
|
60
|
+
|
61
|
+
</script>
|
62
|
+
|
63
|
+
</body>
|
64
|
+
|
65
|
+
</html>
|
26
66
|
|
27
67
|
```
|