-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodeCreate.html
More file actions
44 lines (39 loc) · 1.15 KB
/
Copy pathnodeCreate.html
File metadata and controls
44 lines (39 loc) · 1.15 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
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web Programming</title>
<link rel="stylesheet" href="css/nodelist.css">
</head>
<body>
<div id="container">
<h1>Web Programming</h1>
<p>공부할 주제를 기록해 보세요</p>
<form action="">
<input type="text" id="subject" autofocus>
<button onclick="newRegister(); return false">추가</button>
</form>
<hr>
<ul id="itemList"></ul>
</div>
<script>
function newRegister() {
var newItem = document.createElement("li");
var subject = document.querySelector("#subject");
var newText = document.createTextNode(subject.value);
newItem.appendChild(newText)
var itemList = document.querySelector("#itemList");
itemList.appendChild(newItem);
subject.value="";
var items = document.querySelectorAll("li");
for(i = 0; i < items.length; i++) {
items[i].addEventListener("click", function() {
if(this.parentNode)
this.parentNode.removeChild(this);
})
}
}
</script>
</body>
</html>