首页 > 代码库 > bootstrap 中dropmenu不起作用

bootstrap 中dropmenu不起作用

今天在使用bootstrap发现dropmenu一直不起作用,代码是从官网拷贝过来。

网上查找可以用的页面进行一点点的去除分析,发现竟然是顺序反了导致的。

在使用dropmenu时需要引入jquery.js。而且引入的路径需要在boostrap.js前面。放在后面则不起作用

<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script><script src="http://cdn.bootcss.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

  

 1 <!DOCTYPE html> 2 <html > 3 <head> 4 <title>what页</title> 5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 6 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 7 <link href="resource/css/bootstrap.css" rel="stylesheet" type="text/css" rel="stylesheet"/> 8 <link href="resource/css/what.css" rel="stylesheet" type="text/css" rel="stylesheet"/> 9 10 <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>11 <script src="http://cdn.bootcss.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>12 13 14 15 16   17 </head>18 <body>19 <div class="navbar navbar-inverse navbar-fixed-top">20   <div class="container">21     <div class="navbar-header">22       <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>23       <a class="navbar-brand hidden-sm" href="http://www.bootcss.com">Bootstrap中文网</a> </div>24     <div class="navbar-collapse collapse" role="navigation">25       <ul class="nav navbar-nav">26         <li class="dropdown"> <a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">Bootstrap2中文文档<b class="caret"></b></a>27           <ul class="dropdown-menu">28             <li> <a href="http://v2.bootcss.com/getting-started.html" target="_blank">起步</a> </li>29             <li> <a href="http://v2.bootcss.com/scaffolding.html" target="_blank">脚手架</a> </li>30             <li> <a href="http://v2.bootcss.com/base-css.html" target="_blank">基本CSS样式</a> </li>31             <li> <a href="http://v2.bootcss.com/components.html" target="_blank">组件</a> </li>32             <li> <a href="http://v2.bootcss.com/javascript.html" target="_blank">JavaScript插件</a> </li>33             <li> <a href="http://v2.bootcss.com/customize.html" target="_blank">定制</a> </li>34           </ul>35         </li>36         <li class="dropdown"> <a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">Bootstrap3中文文档<b class="caret"></b></a>37           <ul class="dropdown-menu">38             <li> <a href="http://v3.bootcss.com/getting-started/" target="_blank">起步</a> </li>39             <li> <a href="http://v3.bootcss.com/css/" target="_blank">CSS</a> </li>40             <li> <a href="http://v3.bootcss.com/components/" target="_blank">组件</a> </li>41             <li> <a href="http://v3.bootcss.com/javascript/" target="_blank">JavaScript插件</a> </li>42             <li> <a href="http://v3.bootcss.com/customize/" target="_blank">定制</a> </li>43           </ul>44         </li>45         <li><a href="/p/lesscss/" target="_blank">Less 教程</a></li>46         <li><a href="http://jquery.bootcss.com/" target="_blank">jQuery API</a></li>47         <li><a href="http://expo.bootcss.com" target="_blank">网站实例</a></li>48       </ul>49       <ul class="nav navbar-nav navbar-right">50         <li><a href="/about/">关于</a></li>51       </ul>52     </div>53   </div>54 </div>55 56 </body>
运行测试

 

bootstrap 中dropmenu不起作用