简体   繁体   English

该引导按钮下拉菜单不起作用。 但为什么?

[英]This bootstrap button dropdown is not working. But why?

At first I was using regular html but the dropdown button wasn't working so I changed to jsfiddle to test it out. 最初,我使用的是常规html,但是下拉按钮不起作用,因此我改用jsfiddle进行测试。 I saw that the dropwdown still didn't work. 我看到下拉菜单仍然无法正常工作。

Here's the jsfiddle: https://jsfiddle.net/ugpqxpn6/2/ 这是jsfiddle: https ://jsfiddle.net/ugpqxpn6/2/

<div>

<!-- Single button -->
<div class="btn-group">
  <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Action <span class="caret"></span>
  </button>
  <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 role="separator" class="divider"></li>
    <li><a href="#">Separated link</a></li>
  </ul>
</div>

</div>

I don't understand why it wouldn't work. 我不明白为什么它行不通。 I took a look at some similar questions and saw that maybe not including jquery was my problem so I added it but it still seems to malfunction. 我看了一些类似的问题,发现也许不包括jquery是我的问题,所以我添加了它,但它似乎仍然有故障。 Can anybody help? 有人可以帮忙吗?

Hit F12 on your keyboard to see the developer console, you have a Javascript error: 在键盘上按F12键以查看开发人员控制台,您遇到Javascript错误:

Error: Bootstrap's JavaScript requires jQuery 错误:Bootstrap的JavaScript需要jQuery

Make sure you're including jQuery before bootstrap's js files. 确保在引导程序的js文件之前包含jQuery。

Here is a working fiddle with bootstrap.min.js and jquery.min 这是bootstrap.min.js和jquery.min的有效提琴

https://jsfiddle.net/nrgxh5rr/ https://jsfiddle.net/nrgxh5rr/

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM