Bootstrap选项卡不隐藏非活动div

时间:2012-11-20 00:39:35

标签: twitter-bootstrap tabs

我无法弄清楚如何将*(MSV,HOF,TOES)下面的三个div中的每一个分成每个受尊重的标签。标签工作,并正确显示。我只是无法显示标签。

以下是代码:

<p><i class="icon-heart"></i>&nbsp;Progression</p>

<ul class="nav nav-tabs" id="myTab" data-tabs="tabs">
  <li class="active"><a data-toggle="tab" href="#MSV">MSV</a></li>
  <li><a data-toggle="tab" href="#TOES">ToES</a></li>
  <li><a data-toggle="tab" href="#HoF">HoF</a></li>
</ul>

<div class="tab-content">
<ul class="nav nav-list">

<div class="tab-pain active" id="MSV">
    <li>Mogu'shan Vaults</li>
        <a rel="tooltip" title="Normal">
        <li>
        <div class="progress progress-striped active">
        <div class="bar" style="width: 100%;">6/6</div>
        </div>
        </li>
        </a>

        <a rel="tooltip" title="Heroic">
        <li>
        <div class="progress">
        <div class="bar bar-active" style="width: 3%;"></div>
        <div class="bar bar-danger" style="width: 97%;">0/6</div>
        </div>
        </li>
        </a>
</div>

<div class="tab-pain" id="HOF">
    <li>Heart of Fear</li>
        <a rel="tooltip" title="Normal">
        <li>
        <div class="progress progress-striped active">
        <div class="bar" style="width: 20%;">1/6</div>
        </div>
        </li>
        </a>
</div>      

<div class="tab-pain" id="TOES">        
    <li>Terrace of Endless Spring</li>
        <a rel="tooltip" title="Heroic"><li>
        <div class="progress">
        <div class="bar bar-active" style="width: 3%;"></div>
        <div class="bar bar-danger" style="width: 97%;">0/6</div>
        </div>
        </li>
        </a>
</div>
</div>
</ul>

<script>
$('#myTab a').click(function (e) {
  e.preventDefault();
  $(this).tab('show');
})
</script>

1 个答案:

答案 0 :(得分:2)

请尝试以下代码。您只需删除<Ul>内的<div class="tab-content">并使用<div class="tab-pane">代替<div class="tab-pain">。 同时将href从href =“#HoF”更改为href =“#HOF”。

<p>
    <i class="icon-heart"></i>&nbsp;Progression</p>
<ul class="nav nav-tabs" id="myTab" data-tabs="tabs">
    <li class="active"><a data-toggle="tab" href="#MSV">MSV</a></li>
    <li><a data-toggle="tab" href="#TOES">ToES</a></li>
    <li><a data-toggle="tab" href="#HOF">HoF</a></li>
</ul>
<div class="tab-content">
    <div class="tab-pane active" id="MSV">
        <li>Mogu'shan Vaults</li>
        <a rel="tooltip" title="Normal">
            <li>
                <div class="progress progress-striped active">
                    <div class="bar" style="width: 100%;">
                        6/6</div>
                </div>
            </li>
        </a><a rel="tooltip" title="Heroic">
            <li>
                <div class="progress">
                    <div class="bar bar-active" style="width: 3%;">
                    </div>
                    <div class="bar bar-danger" style="width: 97%;">
                        0/6</div>
                </div>
            </li>
        </a>
    </div>
    <div class="tab-pane" id="HOF">
        <li>Heart of Fear</li>
        <a rel="tooltip" title="Normal">
            <li>
                <div class="progress progress-striped active">
                    <div class="bar" style="width: 20%;">
                        1/6</div>
                </div>
            </li>
        </a>
    </div>
    <div class="tab-pane" id="TOES">
        <li>Terrace of Endless Spring</li>
        <a rel="tooltip" title="Heroic">
            <li>
                <div class="progress">
                    <div class="bar bar-active" style="width: 3%;">
                    </div>
                    <div class="bar bar-danger" style="width: 97%;">
                        0/6</div>
                </div>
            </li>
        </a>
    </div>
</div>
<script>
    $('#myTab a').click(function (e) {
        e.preventDefault();
        $(this).tab('show');
    })
</script>