forked from enshahar/learning-react-kor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path06-let.html
42 lines (36 loc) · 958 Bytes
/
06-let.html
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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no"/>
<meta charset="utf-8">
<style media="screen">
#container {
display: flex;
justify-content: space-around;
}
#container>div {
height: 5em;
width: 5em;
background-color: purple;
}
</style>
<title>Let</title>
<script src="https://unpkg.com/[email protected]/babel.min.js"></script>
</head>
<body>
<h1>박스를 클릭하세요</h1>
<div id="container"></div>
<script type="text/babel">
// Solution, lexical variable scope
var div,
container = document.getElementById('container')
for (let i=0; i<5; i++) {
div = document.createElement('div')
div.onclick = function() {
alert('이것은 박스 #' + i + '입니다.')
}
container.appendChild(div)
}
</script>
</body>
</html>