Bootstrap的下拉菜单不起作用

时间:2014-04-21 17:06:35

标签: html twitter-bootstrap twitter-bootstrap-3

我已经包含了bootstrap-dropdown.js,但不知道它为什么不起作用。

这是我的代码,一切都与文档页面中的代码相同。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="http://twitter.github.io/bootstrap/assets/js/bootstrap-dropdown.js"></script>
<title>Lorem Ipsum</title>
</head>
<body>
<div class="row">
    <div class="container">
        <div class="col-md-5"><h1>Lorem Ipsum</h1></div>
    </div>
</div>

<br>

<div class="row">
    <div class="container">
        <div class="col-md-12">
            <nav class="navbar navbar-default" role="navigation">
              <div class="container-fluid">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <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="#">Brand</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 class="active"><a href="#">Link</a></li>
                    <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 data-toggle="dropdown" href="#">Action</a></li>
                        <li><a data-toggle="dropdown" href="#">Another action</a></li>
                        <li><a data-toggle="dropdown" href="#">Something else here</a></li>
                      </ul>
                    </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 -->
              </div><!-- /.container-fluid -->
            </nav>
        </div>
    </div>
</div>

 

PS。我在文档中搜索。它告诉我,我已经下载了dropdown.js但没有看到任何下载按钮。

1 个答案:

答案 0 :(得分:0)

我正在使用完整的bootstrap-min.js文件,以及jquery 1.11,并且使用下拉菜单处理以下内容:

请注意,您不需要单独的bootstrap-dropdown.js文件,bootstrap.min.js已包含下拉代码。

<!-- Include twitter bootstrap 3.1.1-->
{{ HTML::style('/css/bootstrap.min.css')}}
<!-- Include JQuery -->
<script src="/js/jquery-1.11.0.min.js"></script> 
<!-- Javascript================================= -->
<script src="/js/bootstrap.min.js"></script>

<div id="navbar">
        <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
            <div class="navbar-header">
                <a class="navbar-brand" style="font-size: 24px;" href="http://www.myapp.tld">My App Name</a>
            </div> <!-- End Navbar Header -->

            <ul class="nav navbar-nav">

<!-- My Drop Menu. -->
                <li class="dropdown" id="mydropbar">
                    <a href="#mydropbar" class="dropdown-toggle" data-toggle="dropdown">Menu Name <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <li>{{ HTML::link('/items', 'Item 1') }}</li>
                        <li>{{ HTML::link('items/create', 'Add Item') }}</li>
                        <li>{{ HTML::link('print', 'Print Items') }}</li>
                    </ul>
                </li>
</ul>  <!-- end left ul class nav -->
</nav>  <!-- end navbar -->
</div> <!-- End Div -->