简体   繁体   English

活动的bootstrap选项卡已更改

[英]bootstrap tab on active changed

i have this tab in bootstrap: 我在bootstrap中有这个标签:

<ul class="nav nav-tabs" id="feedtab">
  <li class="active"><a href="#atlass" data-toggle="tab">Atlass</a></li>
  <li><a href="#avi" data-toggle="tab">Aviation</a></li>
  <li><a href="#proc" data-toggle="tab">Processing</a></li>
  <li><a href="#it" data-toggle="tab">IT&S</a></li>
</ul>

<div class="tab-content">
  <div class="tab-pane active" id="atlass"><div id="updates" data-id-type="1"><div class="alert alert-default well" style="background-color: #f1f1f1"><i class="fa fa-spinner fa-spin"></i> Portal is Initilizing... Please Wait.</div></div></div>
  <div class="tab-pane" id="avi"><div class="well" style="background-color: lightsteelblue;">Aviation Feed Will go here.</div></div>
  <div class="tab-pane" id="proc"><div class="well" style="background-color: lightsteelblue;">Processing Feed Will go here.</div></div>
  <div class="tab-pane" id="it"><div class="well" style="background-color: lightsteelblue;">IT&S Feed will go here.</div></div>
</div>

How do i have an event or soemthing in jquery for when the active tab is changed? 当活动标签发生变化时,我如何在jquery中有一个事件或事件?

i want to call a javascript function when the active tab is changed. 我想在更改活动选项卡时调用javascript函数。

i've tried this but dosent work: 我试过这个但是很有效:

<script>

$('#feedtab [data-toggle="tab"]').on('shown.bs.tab', function (e)
{
    alert('test');
})


</script>

Straight out of the documentation 直接退出文档

There are two events that get fired show.bs.tab & shown.bs.tab as their name implies one gets fired before the new content is shown, the other one right after. 有两个事件被触发show.bs.tab和shown.bs.tab,因为它们的名字暗示一个在显示新内容之前被触发,另一个在之后被触发。

$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  //e.target -> activated tab
  //e.relatedTarget -> previous tab
});

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

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