2013-09-16 73 views
0

我使用twitter引導來顯示選項卡。當標籤被稱爲URL應該改變來自:jquery停止更改網址的標籤

example.com/controller 

example.com/controller#tabid 

,但在我的代碼不會發生,除非我刪除的jQuery。爲什麼jquery阻止url被更改?

這是我的代碼: http://jsbin.com/oraFITI/1/edit

<html> 
    <head> 
    <script src="http://code.jquery.com/jquery.min.js"></script> 
    <link type="text/css" rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.css"> 
    <script src="http://getbootstrap.com/dist/js/bootstrap.js"></script> 
    </head> 
<body> 

<ul class="nav nav-tabs"> 
    <li class="active"> 
     <a data-toggle="tab" href="#about">About</a> 
    </li> 
    <li class=""> 
     <a data-toggle="tab" href="#profile">profile</a> 
    </li> 
    <li class=""> 
     <a data-toggle="tab" href="#store">store</a> 
    </li> 
     <li class=""> 
      <a data-toggle="tab" href="#favorite">Favorite</a> 
    </li> 
</ul> 

<div class="tab-content" id="content"> 
    <div id="about" class="tab-pane active">about content</div> 
    <div id="profile" class="tab-pane">profile content</div> 
    <div id="store" class="tab-pane">store content</div> 
    <div id="favorite" class="tab-pane">favorite content</div> 
</div> 

</body> 
</html> 
+0

bootstrap.js需要jQuery的。我認爲你看到的行爲是預期的行爲 –

+0

也許你是對的。點擊標籤時,URL不會改變。這是我不期望的。 – werva

+0

你正在尋找一個導航欄,然後據我瞭解 –

回答

2

您仍然可以設置自己的點擊處理程序:

$('.nav-tabs a').on('click',function(){ window.location.hash = $(this).attr('href'); });