简体   繁体   English

关闭所有自举手风琴

[英]Close all bootstrap accordions

I want to save my accordions as an image with HTML2CANVAS. 我想用HTML2CANVAS将手风琴保存为图像。 For this i open up all accordions and everything's nice, but then they won't close later on. 为此,我打开了所有手风琴,一切都很好,但是后来它们不会关闭。 I digged around and found this great code: 我四处搜寻,发现了以下出色的代码:

function openAccordions(){
    $('.panel-collapse:not(".in")')
    .collapse('show'); 
}

function closeAccordions(){
    $('.panel-collapse.in')
    .collapse('hide'); 
}

By the looks of it and googling around this should work, although the function openAccordions() work but closeAccordions() does not (elements stay collapsed). 从外观上看,应该可以使用它,尽管函数openAccordions()有效,但closeAccordions()无效(元素保持折叠状态)。

Any ideas how to work around or why this particular code might not work? 有任何解决方法或为什么此特定代码可能无法工作的想法?

try check for visibility. 尝试检查可见性。 Like so: 像这样:

function openAccordions(){
    $('.panel-collapse').not(':visible')
    .collapse('show'); 
}

function closeAccordions(){
    $('.panel-collapse').is(':visible')
    .collapse('hide'); 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM