-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove-elements.html
37 lines (35 loc) · 971 Bytes
/
remove-elements.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 http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Removing DOM Elements</title>
<style>
.hidden {
font-size: 50px;
}
</style>
</head>
<body style="text-align: center">
<h1>JavaScript DOM</h1>
<section id="output"></section>
<script>
const output = document.getElementById("output");
output.innerHTML = `
<div>
You think you know me!
</div>
`;
const div = document.createElement("div");
const span = document.createElement("span");
div.append(span);
span.innerText = "Text will disappear soon!";
span.classList.add("hidden"); // add class to element
output.append(div);
setTimeout(() => {
div.remove();
}, 2000);
</script>
</body>
</html>