html
html
1
2
3
4
5
6
7
8
9
10
11
12
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div class="parent">
I am the parent
<p class="child">Click me to remove parent</p>
</div>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
body {
}
.parent{
border:1px solid black;
padding:0.5rem;
}
.child{
border:1px solid black;
padding:0.5rem;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
window.onload = () =>{
const parent = document.querySelector(".parent");
const child = document.querySelector(".child");
child.addEventListener("click",() =>{
parent.remove();
})
}
//OR
/*
window.onload = () =>{
const child = document.querySelector(".child");
child.addEventListener("click",() =>{
child.parentNode.remove();
})
}
*/
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run