[英]Changing aria-expanded=“true” manually not opening new tab
I would like to open another tab after certain action is true. 某些操作为真后,我想打开另一个选项卡。 Here you see my bootstrap navbar and the jQuery script.
在这里,您会看到我的引导导航栏和jQuery脚本。
<ul class="nav navbar-default nav-justified" role="tablist" id="navbar">
<li role="presentation" class="active"><a id="tab1" href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
<li role="presentation" ><a id="tab2" href="#msg" aria-controls="msg" role="tab" data-toggle="tab">Messages</a></li>
</ul>
And here is the script. 这是脚本。
$("#password-button").on("click", function () {
if($("#password-name").val() === password) {
$("#tab1").attr("aria-expanded", "false");
$("#tab2").attr("aria-expanded", "true");
}
}
Firebug shows me that it changes those attributes but nothing happens? Firebug向我展示了它更改了那些属性,但是什么也没发生?
Use .tab()
property to show or hide tab from Jquery. 使用
.tab()
属性在Jquery中显示或隐藏选项卡。 Try this: 尝试这个:
$('.nav-tabs a[href="#tab1"]').tab('show');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.