-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHTMLWithinHTML.html
43 lines (43 loc) · 1.23 KB
/
HTMLWithinHTML.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.container {
height: 200px;
width: 400px;
background-color: red;
}
.hideEl {
display: none;
}
</style>
</head>
<body>
<div class="container">
<div class="container-2">This will hold some content</div>
</div>
<div class="hiddenContainer">
This content will replace the child container and will append itself
inside the parent container.
</div>
<p id="data-p">Some data</p>
<button id="btnHide">HIde</button>
<script>
const container = document.querySelector(".container");
let con = document.querySelector(".hiddenContainer");
let con2 = document.querySelector(".container-2");
let pTag = document.getElementById("data-p");
let btnHide = document.getElementById("btnHide");
btnHide.addEventListener("click", hide(con, pTag, btnHide));
container.innerHTML = con.innerHTML;
function hide(...els) {
els.forEach((el) => {
el.style.display = "none";
});
}
</script>
</body>
</html>