7.2.2 禁用下拉菜单的某个菜单项
如果要禁用某个菜单项,只要为该菜单项对应的<li>
元素添加.disabled
样式即可。
程序示例
例如如下菜单。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| <!DOCTYPE html> <html>
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title> 禁用菜单项 </title> <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="../bootstrap/css/bootstrap-theme.min.css"> </head>
<body> <div class="container"> <div class="row"> <div class="col-sm-3"> <div class="dropdown"> <button class="btn btn-default dropdown-toggle" type="button" id="dropdown3" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> 下拉菜单(带分隔条) <span class="caret"></span> </button> <ul class="dropdown-menu" aria-labelledby="dropdown3"> <li> <a href="#">新建</a> </li> <li class="disabled"> <a href="#">打开</a> </li> <li> <a href="#">保存</a> </li> <li role="separator" class="divider"></li> <li> <a href="#">退出</a> </li> </ul> </div> </div> </div> </div> <script type="text/javascript" src="../jquery-3.1.1.js"></script> <script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script> </body>
</html>
|
原文链接: 7.2.2 禁用下拉菜单的某个菜单项