Javascript 使用jquery更改活动选项卡
我的页面上有两个选项卡(使用引导):Javascript 使用jquery更改活动选项卡,javascript,jquery,twitter-bootstrap,Javascript,Jquery,Twitter Bootstrap,我的页面上有两个选项卡(使用引导): ... ... 当我从“配置文件”选项卡发送POST请求时,我想激活此选项卡,我如何才能做到这一点?文档中有您的确切示例,其中说明要激活选项卡,您需要: $('#myTab a[href="#profile"]').tab('show') 看起来您有一个“活动”类来激活选项卡。在这种情况下,您只需执行以下操作: $("#home").removeClass("active"); // this deactivates the home tab
...
...
当我从“配置文件”选项卡发送POST请求时,我想激活此选项卡,我如何才能做到这一点?文档中有您的确切示例,其中说明要激活选项卡,您需要:
$('#myTab a[href="#profile"]').tab('show')
看起来您有一个“活动”类来激活选项卡。在这种情况下,您只需执行以下操作:
$("#home").removeClass("active"); // this deactivates the home tab
$("#profile").addClass("active"); // this activates the profile tab
试试这个
<ul class="nav nav-tabs" id="myTab">
<li <?php if empty($_POST): ?> class="active" <?php endif; ?> ><a href="#home">Home</a></li>
<li><a href="#profile" <?php if !empty($_POST): ?> class="active" <?php endif; ?>>Profile</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane <?php if empty($_POST): ?> active <?php endif; ?>" id="home">...</div>
<div class="tab-pane <?php if !empty($_POST): ?> class="active" <?php endif; ?>" id="profile">...</div>
</div>
>
<ul class="nav nav-tabs" id="myTab">
<li <?php if empty($_POST): ?> class="active" <?php endif; ?> ><a href="#home">Home</a></li>
<li><a href="#profile" <?php if !empty($_POST): ?> class="active" <?php endif; ?>>Profile</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane <?php if empty($_POST): ?> active <?php endif; ?>" id="home">...</div>
<div class="tab-pane <?php if !empty($_POST): ?> class="active" <?php endif; ?>" id="profile">...</div>
</div>