2017-06-14 189 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

谢谢你的工作 –