Bootstrap下拉列表无法正常工作

时间:2015-11-17 05:55:39

标签: html twitter-bootstrap drop-down-menu twitter-bootstrap-3

我尝试了很多但无法解决此下拉菜单问题。 bootstrap doc如何说我在这里做同样的事情并检查stackoverflow之前的问题答案,但它在我的文件中没有用。我在dropbox上传了我的文件以检查它是否也可以看到here 我的代码如下。

<!DOCTYPE html>
<html>
 <head>

    <title>Hey! Whats up?</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">


    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>

    <!--
    <link rel="icon" type="image/png" href="favicons/favicon-16x16.png" sizes="16x16">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="bootstrap/js/jquery-2.1.4.min.js"></script>

    -->

 </head>

 <body>
    <div class="container">

        <div class="col-md-12">
            <nav class="navbar navbar-inverse">
                <div class="container-fluid">
                    <div class="navbar-header">
                        <a class="navbar-brand" href="#">WebSiteName</a>
                    </div>
                    <div>
                        <ul class="nav navbar-nav">
                            <li class=""><a href="#">Home</a></li>
                            <li class="dropdown">
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1<span class="caret"></span></a>
                            <ul class="dropdown-menu">
                            <li><a href="#">Page 1-1</a></li>
                            <li><a href="#">Page 1-2</a></li>
                            <li><a href="#">Page 1-3</a></li> 
                            </ul>
                            </li>
                            <li><a href="#">Page 2</a></li> 
                            <li><a href="#">Page 3</a></li>


                        </ul>



                        <ul class="nav navbar-nav navbar-right">
                            <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
                            <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
                        </ul>
                    </div>
                </div>
            </nav>
        </div>
     </div>
  </body>
</html>

3 个答案:

答案 0 :(得分:0)

您忘了拨打jquery。根据{{​​3}}:

  

需要jQuery

     

请注意,所有JavaScript插件都需要jQuery   要包括在内,如启动器模板中所示。咨询我们的   bower.json查看支持哪些版本的jQuery。

<head>
    <title>Hey! Whats up?</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="bootstrap/js/jquery-2.1.4.min.js"></script>

    <link rel="icon" type="image/png" href="favicons/favicon-16x16.png" sizes="16x16">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <style type="text/css"></style>
</head>

答案 1 :(得分:0)

在bootstrap之前包含jquery

<script type="text/javascript" src="bootstrap/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>

而不是

<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="bootstrap/js/jquery-2.1.4.min.js"></script>

答案 2 :(得分:0)

确保您的下拉功能已初始化。