需要将下拉列表附加到具有类型“”的图标;按钮”;

Need to attach a dropdown to an icon with type "button"

本文关键字:类型 图标 按钮 下拉列表      更新时间:2023-09-26

我在twitter引导程序容器上有一个图标。我想点击它并显示一个下拉列表,其中包含指向其他网站的链接。现在,我可以得到下拉列表,但它会自动显示在页面上,而无需单击图标,而且每个链接都在一个又一个的顶部。基本上,我想要eclipse中任何"按钮"的功能,如"文件、编辑、源代码、导航…"等,点击它就会出现下拉列表。但我需要这个附在一个图标上。以下是我尝试失败的内容:

  <a id="myIcon" href="#" class="btn-mini" type="button"><i class="icon-wrench"  title="Help" ></i></a>
    <div id="helpMenu" class="menu">
        <a class="menuItem" href="#">Help</a>
        <a class="menuItem" href="#">Ideas</a>
        <a class="menuItem" href="#">Issues</a>
    </div>

我觉得我忽略了一个简单的解决方案。有什么建议吗?

您需要将适当的data-属性添加到标记中,最好将下拉列表放在列表中,例如

<div class="dropdown">
  <a role="button" data-toggle="dropdown" href="#"><i class="icon-wrench"  title="Help" ></i></a>
  <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
    <li role="presentation"><a role="menuItem" href="#">Help</a></li>
    <li role="presentation"><a role="menuItem" href="#">Ideas</a></li>
    <li role="presentation"><a role="menuItem" href="#">Issues</a></li>
  </ul>
</div>