-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventHandler.html
172 lines (165 loc) · 5.75 KB
/
eventHandler.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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<label for="name">이름</label>
<input type="text" name="name" value="Hong">
<label for="name">지위</label>
<input type="text" name="position" value="Developer"><br>
<label for="name">사무실</label>
<input type="text" name="office" value="Seoul">
<label for="name">나이</label>
<input type="text" name="age" value=25><br>
<label for="name">입사일</label>
<input type="text" name="startDate" value="2020/05/01">
<label for="name">급여</label>
<input type="text" name="salary" value=3000><br>
<button id="insert">입력</button>
<table id="example" border='1' style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$86,000</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012/03/29</td>
<td>$433,060</td>
</tr>
<tr>
<td>Airi Satou</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>33</td>
<td>2008/11/28</td>
<td>$162,700</td>
</tr>
<tr>
<td>Brielle Williamson</td>
<td>Integration Specialist</td>
<td>New York</td>
<td>61</td>
<td>2012/12/02</td>
<td>$372,000</td>
</tr>
<tr>
<td>Herrod Chandler</td>
<td>Sales Assistant</td>
<td>San Francisco</td>
<td>59</td>
<td>2012/08/06</td>
<td>$137,500</td>
</tr>
</tbody>
</table>
<button id="btn">클릭</button>
<div>
<label for="name">이름</label>
<input type="text" name="name" value="Hong">
<label for="name">지위</label>
<input type="text" name="position" value="Developer"><br>
<label for="name">사무실</label>
<input type="text" name="office" value="Seoul">
<label for="name">나이</label>
<input type="text" name="age" value=25><br>
<label for="name">입사일</label>
<input type="text" name="startDate" value="2020/05/01">
<label for="name">급여</label>
<input type="text" name="salary" value=3000><br>
<button id="insert">입력</button>
<table id="example" border='1' style="width:100%">
</div>
<script>
let types = document.querySelectorAll("div input");
console.log(types);
let $tr = document.createElement("tr");
for (let i = 0; i < types.length; i++) {
console.log(types[i].value);
let $td = document.createElement("td");
let $text = document.createTextNode(types[i].value);
$td.appendChild($text);
$tr.appendChild($td);
}
let ins = document.getElementById("insert");
ins.addEventListener("click", function () {
let types = document.querySelectorAll("input[type]");
console.log(types)
let $tr = document.createElement("tr");
for (let i = 0; i < types.length; i++) {
console.log(types[i].value);
let $td = document.createElement("td");
let $text = document.createTextNode(types[i].value);
$td.appendChild($text);
$tr.appendChild($td);
let exam = document.getElementById("example");
exam.childNodes[3].appendChild($tr);
$tr.onmouseover = function () {
this.style.background = "yellow";
}
$tr.onmouseout = function () {
this.style.background = "";
}
$tr.onclick = function () {
this.style.display = "none";
}
}
});
let tds = document.querySelectorAll("tbody tr");
console.log(tds);
for (let i = 0; i < tds.length; i++) {
tds[i].addEventListener("mouseover", function () {
this.style.background = "yellow";
});
tds[i].addEventListener("mouseout", function () {
this.style.background = "";
});
tds[i].addEventListener("click", function () {
// this.style.display = "none";
console.log(this.childNodes[7].childNodes[0].nodeValue);
});
}
let btn = document.getElementById("btn");
btn.addEventListener("click", function () {
console.log();
this.style.background = "yellow"
});
</script>
</body>
</html>