Bootstrap下拉列表无效

时间:2016-02-27 07:46:02

标签: html twitter-bootstrap

什么技巧可以让我的下拉工作,因为我尝试过其他技巧,但无济于事。代码如下。感谢

<!DOCTYPE html>
<html>
<head>
    <title>test</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js">    </script>

    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js">    </script>
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">

</head>
<body>

  <div class="btn-group"> 
    <button id="myid" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
Action <span class="caret"></span>
    </button>
 <ul class="dropdown-menu" role="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>
</div>
</body>
</html>

2 个答案:

答案 0 :(得分:0)

要从下拉列表中禁用菜单项,请使用disabled类:

<ul class="dropdown-menu" role="menu">
    <li><a href="#">Action</a></li>
    <li class="disabled"><a href="/">Another action (disabled)</a></li>
    <li><a href="#">Something else here</a></li>
    <li class="divider"></li>
    <li><a href="#">Separated link</a></li>
</ul>

并阻止点击使用jQuery:

<script>

    $(".disabled > a").click(function(event) {
      return false;
    });

</script>

答案 1 :(得分:0)

<head>
<title>test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.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">

</head>

我认为你的CDN可能会给你带来麻烦。用这个替换你<head> </head> ^看看是否有效