简体   繁体   English

使用按钮单击Tabs Bootstrap 3选项卡上的问题

[英]Issue on Tabbing Bootstrap 3 Tab Using Button Click

an you please take a look at This Demo and let me know why I am not able to tab bootstrap 3 tabbs by clicking on the the buttons? 一个,请看一下这个演示 ,让我知道为什么我不能通过单击按钮来设置bootstrap 3 tabbs?

Here is the code I have: 这是我的代码:

<div class="btn-group">
    <button class="btn btn-default" id="one">1</button>
    <button class="btn btn-default" id="two">2</button>
    <button class="btn btn-default" id="three">3</button>
    <button class="btn btn-default" id="four">4</button>
</div>
<div class="container">
    <ul class="nav nav-tabs" id="myTab">
        <li class="active"><a href="#home">1</a> </li>
        <li><a href="#profile">2</a></li>
        <li><a href="#messages">3</a></li>
        <li><a href="#settings">4</a></li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane active" id="home">One</div>
        <div class="tab-pane" id="profile">Two</div>
        <div class="tab-pane" id="messages">Three</div>
        <div class="tab-pane" id="settings">Four</div>
    </div>
</div>
<script>
 $('#myTab a').click(function (e) {
    e.preventDefault();
    $(this).tab('show');
});
$("#one").on("click", function () {
      ('#myTab a:last').tab('show');
});
</script>

Thanks 谢谢

Have you included jQuery, Bootstrap CSS and JS? 您是否包括jQuery,Bootstrap CSS和JS?

Edit: 编辑:

Solution: You forgot the '$' sign, at the front, for jQuery. 解决方案:您忘记了jQuery前面的“ $”符号。

$('#myTab a:last').tab('show');

Take a look at the following JS Bin for solution: http://jsbin.com/fenapota/2/edit?html,output 查看以下JS Bin作为解决方案: http : //jsbin.com/fenapota/2/edit?html,输出

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

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