-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprac8-9.html
37 lines (37 loc) · 991 Bytes
/
prac8-9.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DomPrac9</title>
<style>
ol {
list-style-type: upper-alpha;
}
</style>
<script>
function change(obj) {
let doc = document.getElementById("parent"); //객체 가져오기(아이디로)
let newli = document.createElement("li");
let user = prompt("라면 끓이는 순서 입력>> ");
if (user == null) {
document.write("입력된 값이 없습니다.");
} else {
newli.innerHTML = user;
doc.appendChild(newli); //가져온 ol 객체에 자식으로 붙이기
}
}
</script>
</head>
<body>
<h3>라면을 끓이는 순서</h3>
<hr />
<ol
id="parent"
style="background-color: yellowgreen"
onclick="change(this)"
>
<li>물을 끓인다</li>
</ol>
</body>
</html>