可点击的多级菜单

时间:2016-07-26 12:28:22

标签: jquery html css twitter-bootstrap

我想做一个这样的菜单http://bootsnipp.com/snippets/featured/multi-level-dropdown-menu-bs3,它必须是多级菜单,但我想只用点击打开菜单,也可以打开多级菜单,而不是鼠标悬停。此外,如果菜单打开并单击正文将关闭所有菜单。有人有任何想法吗?

提前致谢。

HTML

Map<String,Integer> newMap = 
    s.entrySet().stream()
                .collect(Collectors.toMap(Map.Entry::getValue,Map.Entry::getKey));

CSS

string cubeinline = "12345123451234X1234512345";
List<string> cube = new List<string>(){ "12345",
                                    "12345",
                                    "1234X",
                                    "12345",
                                    "12345"};
bool isEqual = cubeinline == string.Concat(cube);

JS

<div class="container">
    <div class="row">
        <div class="dropdown">
            <a id="dLabel" role="button" data-toggle="dropdown" class="btn btn-primary" data-target="#" href="/page.html">
                Dropdown <span class="caret"></span>
            </a>
            <ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu">
              <li><a href="#">Some action</a></li>
              <li><a href="#">Some other action</a></li>
              <li class="divider"></li>
              <li class="dropdown-submenu">
                <a tabindex="-1" href="#">Hover me for more options</a>
                <ul class="dropdown-menu">
                  <li><a tabindex="-1" href="#">Second level</a></li>
                  <li class="dropdown-submenu">
                    <a href="#">Even More..</a>
                    <ul class="dropdown-menu">
                        <li><a href="#">3rd level</a></li>
                        <li><a href="#">3rd level</a></li>
                    </ul>
                  </li>
                  <li><a href="#">Second level</a></li>
                  <li><a href="#">Second level</a></li>
                </ul>
              </li>
            </ul>
        </div>
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

解决方案是:

JS

$(function(){
    $(".dropdown-submenu").on("click",function(e){
    var current=$(this).find(".dropdown-menu").first();
    console.log(current);
        current.toggle();
        e.stopPropagation();
    });


 $(document).click(function(){
   $(".dropdown-menu").hide('slow'); 
});


});