2017-06-14 185 views
0

我想在我的網站使用引導導航欄,所以我所做的網頁header.html中(如下鏈接),它工作正常引導導航欄下拉不切換

http://upscfever.com/upsc-fever/header.html

然而當我在我的主頁上使用相同的代碼(下面的鏈接)。它在打開後不會關閉。

http://upscfever.com/upsc-fever/index.html

在我的主頁 - index.html的我已經寫了下面的代碼。

 <script> 
      $(function() { 
       $("#header").load("http://upscfever.com/upsc-fever/header.html"); 
       }); 
     </script> 

<body> 
<div id="header"></div> 
<!-- other things--> 
</body> 

我得到的錯誤:

jQuery.Deferred exception: $(...).dropdown is not a function @http://upscfever.com/upsc-fever/index.html:1:15 g/https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:29946 g/https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:30262

回答

0
你可能想要把 load腳本只是body標籤結束前,讓 <div id="header">被使用之前加入到DOM

。 還要確保你不是在你的index.html文件中多次加載bootstrap js。

+0

完成但仍然無法正常工作。在header.html中有一個bootstrap.js,在index.html中有一個是可以的。 –

+0

Hi @pranav nerurkar,你只需要加載一個bootstrap.js,所以既然你已經在header.html中有了它,你應該刪除index.html中的那個。 –

+0

謝謝你的工作 –