Bootstrap下拉按钮不适用于版本3.3.6

时间:2016-03-08 16:40:27

标签: javascript jquery twitter-bootstrap

我正在尝试按照引导按钮下拉,但不能正常工作。

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" >
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>


<div class="dropdown" style="display: block;">
    <ul class="dropdown-menu">
        <li><a href="#" tabindex="-1">Walter</a></li>
        <li><a href="#" tabindex="-1">Bunny</a></li>
        <li><a href="#" tabindex="-1">Big Lewaoaski</a></li>
    </ul>
</div>

修改

<!DOCTYPE html>
<html>
<head>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" >

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" >
<link rel="stylesheet" href="https://bootswatch.com/cosmo/bootstrap.min.css" >


<!-- Latest compiled and minified JavaScript -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <title>Components Tutorial</title>
</head>
<body>
<div class="dropdown" style="display: block;">
    <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
      Dropdown Example <span class="caret"></span>
    </button>
    <ul class="dropdown-menu">
        <li><a href="#" tabindex="-1">Walter</a></li>
        <li><a href="#" tabindex="-1">Bunny</a></li>
        <li><a href="#" tabindex="-1">Big Lewaoaski</a></li>
    </ul>
</div>
</body>
</html>

1 个答案:

答案 0 :(得分:2)

除了丢失的>外,如果不是拼写错误,则不包括用于切换菜单的下拉按钮。

e.g。

<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
  Dropdown Example <span class="caret"></span>
</button>

所以把它放在你当前的代码上:

<div class="dropdown" style="display: block;">
    <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
      Dropdown Example <span class="caret"></span>
    </button>
    <ul class="dropdown-menu">
        <li><a href="#" tabindex="-1">Walter</a></li>
        <li><a href="#" tabindex="-1">Bunny</a></li>
        <li><a href="#" tabindex="-1">Big Lewaoaski</a></li>
    </ul>
</div>

<强> Example Fiddle