【发布时间】:2019-01-05 20:37:03
【问题描述】:
我试图在按下“可折叠”按钮后隐藏它。
activities.html:
<button class="collapsible"> <i class="fa fa-angle-down"></i></a></button>
Controller.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 gallery1 = this.nextElementSibling;
if (gallery1.style.maxHeight){
gallery1.style.maxHeight = null;
} else {
gallery1.style.maxHeight = gallery1.scrollHeight + "px";
}
});
}
如果有人能帮我解决这个问题,我将不胜感激!
【问题讨论】:
-
请正确写代码,你没有忘记加个开头
<a ...>?
标签: javascript html button collapsable