Bootstrap 3选项卡仅在第一个选项卡上显示的数据

时间:2015-10-16 07:13:31

标签: javascript jquery html twitter-bootstrap tabs

我在选项卡中使用Bootstrap 3选项卡和手风琴。

我目前拥有的html如下:

    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#1270013" aria-controls="#1270013" role="tab" data-toggle="tab">DF</a></li>
        <li role="presentation"><a href="#1270015" aria-controls="#1270015" role="tab" data-toggle="tab">HWR</a></li>
    </ul>
    <div class="tab-content">
        <div role="tabpanel" class="tab-panel active" id="1270013">
            <div class="panel-group" id="accordion3" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                    <div class="panel-heading" role="tab" id="heading30">
                        <h4 class="panel-title"><a role="button" data-toggle="collapse" data-parent="#accordion3" href="#collapse30" aria-expanded="true" aria-control="collapse30">2015-10-14 13:36:34</a></h4>
                    </div>
                    <div id="collapse30" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="heading30">
                        <div class="panel-body">
                           ...
                        </div>
                    </div>
                </div>
                <div class="panel panel-default">
                    <div class="panel-heading" role="tab" id="heading31">
                        <h4 class="panel-title"><a role="button" data-toggle="collapse" data-parent="#accordion3" href="#collapse31" aria-expanded="true" aria-control="collapse31">2015-10-14 11:46:26</a></h4>
                    </div>
                    <div id="collapse31" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading31">
                        <div class="panel-body">
                        ...
                        </div> 
                    </div>
                </div>
                <div class="panel panel-default">
                    <div class="panel-heading" role="tab" id="heading31">
                        <h4 class="panel-title"><a role="button" data-toggle="collapse" data-parent="#accordion3" href="#collapse31" aria-expanded="true" aria-control="collapse31">2015-10-14 11:46:26</a></h4>
                    </div>
                    <div id="collapse31" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading31">
                        <div class="panel-body">
                            ...
                        </div>
                    </div>
                </div>
                <div class="panel panel-default">
                    <div class="panel-heading" role="tab" id="heading32">
                        <h4 class="panel-title"><a role="button" data-toggle="collapse" data-parent="#accordion3" href="#collapse32" aria-expanded="true" aria-control="collapse32">2015-10-14 09:56:14</a></h4>
                    </div>
                    <div id="collapse32" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading32">
                        <div class="panel-body">
                            ...
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div role="tabpanel" class="tab-panel" id="1270015">
            <div class="panel-group" id="accordion5" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                    <div class="panel-heading" role="tab" id="heading50">
                        <h4 class="panel-title"><a role="button" data-toggle="collapse" data-parent="#accordion5" href="#collapse50" aria-expanded="true" aria-control="collapse50">2015-10-14 14:08:31</a></h4>
                    </div>
                    <div id="collapse50" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="heading50">
                        <div class="panel-body">
                            ...
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

现在此代码显示上面的2个选项卡,但第二个选项卡中的数据将显示在第一个选项卡数据下方。

我无法找到错误,为什么第二个标签数据不会在第二个标签中显示而不是在第一个标签中显示。

我使用的是jQuery 1.9.1和当前的Bootstrap 3版本。

此外,我没有自己编写的JavaScript,我使用HTML中的数据标记。

jsFiddle

2 个答案:

答案 0 :(得分:3)

更改班级名称

第一个标签内容

tab-pane fade in active

第二个标签内容

tab-pane fade

演示链接http://jsfiddle.net/s9s5m3n3/2/

答案 1 :(得分:1)

一切都很好

.tab-panel.tab-pane

的内部内容标签#1270013的班级名称更改为#1270015

请参阅小提琴:http://jsfiddle.net/sachinkk/s9s5m3n3/3/