强制打开至少一个手风琴引导程序选项卡 [英] Force open minimum one accordion bootstrap tab

查看:21
本文介绍了强制打开至少一个手风琴引导程序选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找以下相同的解决方案.我想在这个例子中添加更多,但由于声誉点低而无法发表评论,所以在这里添加

I am looking for the same following solution. I wanted to add more in this example but unable to comment due to low reputation points so adding here

Bootstrap Collapse Accordion 一个面板打开,所有其他面板关闭

我希望在此示例中始终打开一个选项卡.链接中给出的上述示例中有以下选项卡叮咬和叮咬宠物健康与安全牲畜健康与安全,等

I want in this example that one tab always should be open. There are following tabs in the above example given in the link Bites and Stings Pet Health and Safety Livestock Health and Safety, etc.

因此,如果我单击牲畜健康与安全",它会打开此选项卡,然后单击宠物健康与安全",它会打开并关闭牲畜健康与安全".

So if i click on "Livestock Health and Safety" it opens this tab and then click on "Pet Health and Safety" it opens this and close the "Livestock Health and Safety".

所以我的问题是,如果我再次单击同一个选项卡,它不应该关闭.即始终应处于打开状态.

So my question is if i click again on the same tab it should not closed. i.e. One always should be in open state.

希望它清除.

推荐答案

检查这支笔:Codepen 链接

我所做的是将以下 javascript 添加到代码中.

What I have done is add the following javascript to the code.

$('.panel-heading a').on('click',function(e){
   if($(this).parents('.panel').children('.panel-collapse').hasClass('in')){
        e.stopPropagation();
    }
});

希望这会有所帮助.

这篇关于强制打开至少一个手风琴引导程序选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆