Bootstrap AJAX选项卡不起作用,没有任何反应

时间:2015-04-03 15:01:07

标签: javascript ajax twitter-bootstrap

当我点击"工具"选项卡,:标签不会切换,不会切换。



$('[data-toggle="tab"]').click(function(e) {
	var $this = $(this),
		loadurl = $this.attr('href');

	$.get(loadurl, function(data) {
		$('#content').html(data);
	});

	$this.tab('show');
	return false;
});

<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap-combined.min.css" rel="stylesheet"/>
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div class="container">
      <ul class="nav nav-tabs nav-justified" role="tablist">
        <li role="navigation" class="active"><a href="/engine/ajax/main.php" aria-controls="main" role="tab" data-toggle="tab">My links</a></li>
        <li role="navigation"><a href="#tools" aria-controls="stat" role="tab" data-toggle="tab">Statistics</a></li>
        <li role="navigation"><a href="/engine/ajax/tools.php" aria-controls="tools" role="tab" data-toggle="tab">Tools</a></li>
        <li role="navigation"><a href="#payments" aria-controls="payments" role="tab" data-toggle="tab">Payments</a></li>
      </ul>
    </div>

    <div id="content" class="container">

    </div>
&#13;
&#13;
&#13;

我哪里错了?

1 个答案:

答案 0 :(得分:0)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

之前

<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script>

像这样:

<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap-combined.min.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script>

bootstrap.min.js要求jquery.min.js在它之前先运行。