-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday3_javaScript_tuto4_inline.html
More file actions
81 lines (78 loc) · 2.01 KB
/
day3_javaScript_tuto4_inline.html
File metadata and controls
81 lines (78 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
#header {
margin: auto;
}
#main {
border: 3px solid blue;
text-align: center;
}
#result {
margin: auto;
}
</style>
</head>
<body>
<script>
window.onload = function() {
var arr = new Array();
document.getElementById('1').onclick = function(){
gugu(1);
document.getElementById('1').onclick = null;
}
document.getElementById('2').onclick = function(){
gugu(2);document.getElementById('2').onclick = null;
}
document.getElementById('3').onclick = function(){
gugu(3);document.getElementById('3').onclick = null;
}
document.getElementById('4').onclick = function(){
gugu(4);document.getElementById('4').onclick = null;
}
document.getElementById('5').onclick = function(){
gugu(5);document.getElementById('5').onclick = null;
}
document.getElementById('6').onclick = function(){
gugu(6);document.getElementById('6').onclick = null;
}
document.getElementById('7').onclick = function(){
gugu(7);document.getElementById('7').onclick = null;
}
document.getElementById('8').onclick = function(){
gugu(8);document.getElementById('8').onclick = null;
}
document.getElementById('9').onclick = function(){
gugu(9);document.getElementById('9').onclick = null;
}
}
function gugu(num) {
var result = "";
for (var i = 1; i <= 9; ++i) {
result += num + " * " + i + " = " + (num * i) + "<br>";
}
document.getElementById("result").innerHTML = result;
}
</script>
<div id='main'>
<header id="header">
<h2>구구단</h2>
</header>
<br>
<button id='1'>1단</button>
<button id='2'>2단</button>
<button id='3'>3단</button>
<button id='4'>4단</button>
<button id='5'>5단</button>
<button id='6'>6단</button>
<button id='7'>7단</button>
<button id='8'>8단</button>
<button id='9'>9단</button>
<br>
<h5 id='result'></h5>
</div>
</body>
</html>