刷新后保持accordion选项卡打开(引导代码)

时间:2017-02-06 17:13:05

标签: javascript html bootstrap-accordion

刷新网页后,如何保持活动标签处于打开状态。我使用了bootstrap(w3school)代码;

<script>
var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
    acc[i].onclick = function() {
        this.classList.toggle("active");
        var panel = this.nextElementSibling;
        if (panel.style.maxHeight){
            panel.style.maxHeight = null;
        } else {
            panel.style.maxHeight = panel.scrollHeight + "px";
        }
    }
}
</script>

HTML

<button class="accordion"><div class="panel-heading">Application Usages</div></button>

谢谢

0 个答案:

没有答案