1

子菜单在以下代码中无法正常工作。你能提供解决方案吗?

这是代码, http://jsfiddle.net/4UVt3/1/

同样的小提琴复制粘贴在这里,

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">    
    <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"> </script>
    <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"></script>
  </head>
  <body>
  <div class="dropdown">
  <a class="dropdown-toggle" data-toggle="dropdown" href="#">Dropdown trigger</a>
   <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
      <li><a tabindex="-1" href="#">Action</a></li>
      <li><a tabindex="-1" href="#">Another action</a></li>
      <li><a tabindex="-1" href="#">Something else here</a></li>
      <li class="dropdown-submenu">
        <a tabindex="-1" href="#">More options</a>
        <ui class="dropdown-menu">
          <li><a tabindex="-1" href="#">Submenu 1</a></li>
          <li><a tabindex="-1" href="#">Submenu 2 </a></li>
          <li><a tabindex="-1" href="#">Submenu 3 </a></li>
        </ui>
      </li>
    </ul>
  </div>
  </body>
</html>
4

2 回答 2

3

您在子菜单下拉菜单中有错字。它指定为“ui”而不是“ul”。

将您的子菜单下拉菜单更改为

<ul class="dropdown-menu">
    <li><a tabindex="-1" href="#">Submenu 1</a></li>
    <li><a tabindex="-1" href="#">Submenu 2 </a></li>
    <li><a tabindex="-1" href="#">Submenu 3 </a></li>
</ul>
于 2012-12-12T14:44:24.767 回答
3
    <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewporta" content="width=device-width, initial-scale=1.0">    
    <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"> </script>
    <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"></script>
  </head>
  <body>
  <div class="dropdown">
  <a class="dropdown-toggle" data-toggle="dropdown" href="#">Dropdown trigger</a>
   <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
      <li><a tabindex="-1" href="#">Action</a></li>
      <li><a tabindex="-1" href="#">Another action</a></li>
      <li><a tabindex="-1" href="#">Something else here</a></li>
      <li class="dropdown-submenu">
        <a tabindex="-1" href="#">More options</a>
        <ul class="dropdown-menu">
          <li><a tabindex="-1" href="#">Submenu 1</a></li>
          <li><a tabindex="-1" href="#">Submenu 2 </a></li>
          <li><a tabindex="-1" href="#">Submenu 3 </a></li>
        </ul>
      </li>
    </ul>
  </div>
  </body>
</html>

您使用的是 ui 而不是 ul,上面的代码是工作版本,下面是更改。

        <ul class="dropdown-menu">
          <li><a tabindex="-1" href="#">Submenu 1</a></li>
          <li><a tabindex="-1" href="#">Submenu 2 </a></li>
          <li><a tabindex="-1" href="#">Submenu 3 </a></li>
        </ul>
于 2012-12-12T15:09:41.627 回答