Home › Forums › JavaScript › Help w/ Running Multiple Javascripts › Reply To: Help w/ Running Multiple Javascripts
October 26, 2019 at 7:16 pm
#297939
Participant
Hey! I’ve researched this a bit more but still can’t seem to make it work as I can’t find a clear tutorial on how to do it properly. I’ve attempted the DomContentLoaded event listener but my collapsible content still won’t work. Sorry, I’m a complete wreck when it comes to coding ahah
Would you be able to help me figure out how to write it specifically? Because this is what I’ve done, and I think there’s something still missing. Thanks in advance!
var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener ("DOMContentLoaded", ready) ("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.maxHeight){
content.style.maxHeight = null;
} else {
content.style.maxHeight = content.scrollHeight + "px";
}
});
}