MCW
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by MCW
-
-
https://www.w3schools.com/howto/howto_js_collapsible.asp
Whenever I use the code modified or direct into an html, it works in Edge, Chrome and Firefox and not in IE. Any idea what would cause this?
Thanks!
Collapsible not working in IE
in JavaScript
Posted
I am pretty new to this, or several years removed being more like it. I replaced toggle with contains. How else would I change this. Thanks!
<script>
var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll.addEventListener("click", function() {
this.classList.contains("active");
var content = this.nextElementSibling;
if (content.style.display === "block") {
content.style.display = "none";
} else {
content.style.display = "block";
}
});
}
</script>