<
head
>
<
style
>
.collapse {
background-color: #a2de96;
border: none;
outline: none;
font-size: 25px;
}
.active,
.collapse:hover {
background-color: #438a5e;
}
.text {
background-color: #e1ffc2;
display: none;
font-size: 20px;
}
</
style
>
<
head
>
<
body
>
<
h1
style
=
"color:green"
>GeeksforGeeks</
h1
>
<
button
type
=
"button"
class
=
"collapse"
>
Open Collapsible section
</
button
>
<
div
class
=
"text"
>
A Computer Science portal for geeks.
It contains well written, well thought
and well explained computer science and
programming articles, quizzes and ...
</
div
>
<
script
>
let btn = document.getElementsByClassName("collapse");
btn[0].addEventListener("click", function () {
this.classList.toggle("active");
let content = this.nextElementSibling;
if (content.style.display === "block") {
content.style.display = "none";
} else {
content.style.display = "block";
}
});
</
script
>
</
body
>