[英]Why isn't the dropdown menu working in my navbar when I click it?
I am practicing creating a navbar using Bootstrap 3.3.7 and the dropdown is not working when I click on it. 我正在练习使用Bootstrap 3.3.7创建导航栏,并且单击该下拉列表时不起作用。 I have my scripts referenced correctly and I have the latest version of jquery but its still not budging.
我正确引用了我的脚本,并且拥有最新版本的jquery,但它仍然没有进展。 The code is below.
代码如下。 Can anyone help?
有人可以帮忙吗?
!DOCTYPE html>
<html lang="EN-US">
<head>
<title></title>
<link rel="stylesheet" href="Styles/bootstrap.min.css" />
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<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="#">Title</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
<script src="Scripts/jquery-3.1.0.min.js"></script>
<script src="Scripts/bootstrap.min.js"></script>
</body>
I think you haven't linked your resources properly. 我认为您没有正确链接资源。 I tried it out and it worked.
我尝试了一下,它奏效了。 Maybe something like this:
也许是这样的:
<link rel="stylesheet" href="../Styles/bootstrap.min.css" />
You can always use a cdn link for bootstrap. 您可以始终使用CDN链接进行引导。
https://www.bootstrapcdn.com/ https://www.bootstrapcdn.com/
Fiddle: https://jsfiddle.net/5f42fkcb/ 小提琴: https : //jsfiddle.net/5f42fkcb/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.