I came across this animated collapsible code that I'm using:
https://www.w3schools.com/howto/howto_js_collapsible.asp
Here is the HTML:
<button type="button" class="collapsible">Open Collapsible</button>
<div class="content">
<p>Lorem ipsum...</p>
</div>
CSS:
/* Styling for the button used to open and close the collapsible content */
.collapsible {
background-color: #eee;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
}
/* Background color change when clicked or hovered */
.active, .collapsible:hover {
background-color: #ccc;
}
/* Styles for the collapsible content. Initially hidden */
.content {
padding: 0 18px;
display: none;
overflow: hidden;
background-color: #f1f1f1;
}
JS:
var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.display === "block") {
content.style.display = "none";
} else {
content.style.display = "block";
}
});
}
I am trying to add another collapsible button inside the first dropdown. However, currently, my nested button only changes to a minus sign when clicked. Here is the HTML:
<button type="button" class="collapsible">Options:</button>
<div class="content">
<button class="collapsible">Check</button>
<div id="content">
TEST
</div>
</div>
The CSS and JS remain the same as in the provided link.