Forum Moderators: open
var panel = this.nextElementSibling;
if (panel.style.maxHeight){
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
that maxHeight = null; is where the problem starts. max-height: 0; I've worked for days on setting up a series of dropdown lists of varying lengths so I can't set a specific max height for the panel element. I do not know why the script functions fine outside of the WP environment since it is a basic .js script and that hasn't been replaced afaik. Can I just replace "null" with "0" in the script and at least get it functioning? panel.style.maxHeight = ''; [edited by: robzilla at 7:03 pm (utc) on Jul 17, 2021]
if (panel.style.maxHeight){
var acc = document.getElementsByClassName("dropdown");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.maxHeight){
panel.style.maxHeight = 'none';
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
});