Javascript 引导下拉菜单不起作用
我正在尝试使用下拉菜单制作导航栏,但由于某些原因,下拉菜单不起作用。我不知道我是否正确链接了JavaScript文档,但每个人都是这样做的,但下拉菜单仍然不起作用 这是我的代码:Javascript 引导下拉菜单不起作用,javascript,jquery,html,twitter-bootstrap,Javascript,Jquery,Html,Twitter Bootstrap,我正在尝试使用下拉菜单制作导航栏,但由于某些原因,下拉菜单不起作用。我不知道我是否正确链接了JavaScript文档,但每个人都是这样做的,但下拉菜单仍然不起作用 这是我的代码: <head> <style type="text/css"> body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, p, blockquote, th, td, ifra
<head>
<style type="text/css">
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, p, blockquote, th, td, iframe {
margin: 0px;
padding: 0px;
}
</style>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/bootstrap.css.map" rel="stylesheet">
<link href="css/bootstrap.min.css.map" rel="stylesheet">
<link href="css/bootstrap-theme.css" rel="stylesheet">
<link href="css/bootstrap-theme.css.map" rel="stylesheet">
<link href="css/bootstrap-theme.min.css" rel="stylesheet">
<link href="css/bootstrap-theme.min.css.map" rel="stylesheet">
<script src="js/bootstrap.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/npm.js"></script>
</head>
<body >
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">list</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="" class="choice">Announcements</a></li>
<li><a href="" class="choice">GetMotivated</a></li>
<li><a href="" class="choice">Jokes</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Categories <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="" class="choice">LifeProTips</a></li>
<li><a href="" class="choice">TV</a></li>
<li><a href="" class="choice">worldnews</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</body>
正文,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,th,td,iframe{
边际:0px;
填充:0px;
}
切换导航
-
更改
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/bootstrap.css.map" rel="stylesheet">
<link href="css/bootstrap.min.css.map" rel="stylesheet">
<link href="css/bootstrap-theme.css" rel="stylesheet">
<link href="css/bootstrap-theme.css.map" rel="stylesheet">
<link href="css/bootstrap-theme.min.css" rel="stylesheet">
<link href="css/bootstrap-theme.min.css.map" rel="stylesheet">
<script src="js/bootstrap.js"></script>
<script src="js/bootstrap.min.js"></script>
到
正如在注释中提到的,您不需要同时加载文件的.min和not.min部分,而且根本不需要加载.map文件
如果调试需要,您可以切换到使用非.min版本的文件。我所要做的就是包括jquery
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
瞧,它成功了您看到控制台中有错误吗?-你能再多描述一点:“行不通”吗?什么不起作用?你包含了太多的文件。你不需要包含
.min.css
和.css
;它们都包含相同的内容。还有一些是.min.js
和.js
,.min.css.map
和.css.map
(我认为你根本不需要.map
文件)还有一件事,你确定你包含的文件在“css”文件夹中吗?“js”文件夹中的javascript?Bootstrap需要jQuery:我刚刚将它改为这个,drop-not菜单仍然没有drop-down为jQuery添加了一个脚本。用一个本地副本替换它,同样,只包括.min或非.min
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>