我正在尝试以编程方式更改选项卡,如下所示:
<ul class="nav nav-tabs" role="tablist">
<li class="active"><a href="#step1" data-toggle="tab" >Step 1</a></li>
<li><a href="#step2" data-toggle="tab" >Step 2</a></li>
</ul>
<div class="tab-content" id="tabs">
<div id="step1" class="tab-pane fade in active">
</div>
<div id="step2" class="tab-pane fade">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
JS(在一定条件下):
$('a[href="#step2"]').tab('show');
Run Code Online (Sandbox Code Playgroud)
这不起作用,我收到错误消息:TypeError: $(...).tab is not a function
有任何想法吗?
编辑:
可以肯定的是,根据引导程序网站,我还在我的 _Layout 文件中包含了以下内容:
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
Run Code Online (Sandbox Code Playgroud)