创建 jQuery UI 手风琴混合模式
Create jQuery UI Accordion Mixed Mode
谁能告诉我如何实现混合手风琴,其中只有少数节点可以展开或折叠,而其余节点不应该。
只是添加我实现的方式,以便如果有人需要可以参考它。
我在需要手风琴的地方使用了带有自定义 class“.custom-accordion”的
标签。并跳过了另一个我不想要手风琴的 。
准备好文档 -> 我已经处理了 onclick 事件以隐藏后续面板,如下所示:
$(".custom-accordion").on("click", function (e) {
var $accordionPanel = $(this);
$accordionPanel.toggleClass("active");
var panel = $accordionPanel.next();
if (panel.css('max-height') != "0px") {
panel.css('max-height', '0px');
} else {
//panel.css('max-height', panel[0].scrollHeight + "px");
panel.css('max-height', "none");
}
$accordionPanel.attr('aria-expanded', ($accordionPanel.attr('aria-expanded') == 'false' ? 'true' : 'false'));
});
谁能告诉我如何实现混合手风琴,其中只有少数节点可以展开或折叠,而其余节点不应该。
只是添加我实现的方式,以便如果有人需要可以参考它。
我在需要手风琴的地方使用了带有自定义 class“.custom-accordion”的
准备好文档 -> 我已经处理了 onclick 事件以隐藏后续面板,如下所示:
$(".custom-accordion").on("click", function (e) {
var $accordionPanel = $(this);
$accordionPanel.toggleClass("active");
var panel = $accordionPanel.next();
if (panel.css('max-height') != "0px") {
panel.css('max-height', '0px');
} else {
//panel.css('max-height', panel[0].scrollHeight + "px");
panel.css('max-height', "none");
}
$accordionPanel.attr('aria-expanded', ($accordionPanel.attr('aria-expanded') == 'false' ? 'true' : 'false'));
});