使用href链接展开多个下拉菜单 [英] Expand multiple dropdown menus using a href link

查看:80
本文介绍了使用href链接展开多个下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在标题导航中,我希望通过允许用户单击 href 链接来扩展3个下拉开关?

In my header nav, I have 3 dropdown toggles which I am hoping to be able to expand by allow the user to click on a href link?

这是我的下拉导航代码:

Here is my dropdown Nav code:

<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
    <i class="fa fa-question-circle fa-fw"></i> <i class="fa fa-caret-down"></i>
</a>

<ul class="dropdown-menu dropdown-alerts">
    <div class="" style="overflow-y: scroll;height:385px;width:350px; padding-left:0.5cm">
        <b>Support</b> Tickets
        <li class="divider"></li>
        <li>
            <a class="text-center" href="messages.php?show=support">
                <strong>See All Open Tickets</strong><i class="fa fa-angle-right"></i>
            </a>
        </li> 
    </div>
</ul>

当用户单击页面上其他位置的链接时,是否有一种方法可以打开它,例如:

Is there a way I can open this when a user clicks a link located somewhere else on the page, such as:

< a href =#dropdown-toggle">打开下拉菜单</a>

还是类似的东西?

推荐答案

您的代码看起来有些奇怪,但我只是给您一个一般的想法.

Your code looks a little strange, but I'll just give you a general idea.

HTML

<a href="#" id="open">Open Dropdowns</a>

JS

$('#open').onclick(function(){
    $('.dropdown-toggle').click();
});

javascript的作用是,当您单击ID为打开"的元素时,它将模拟对类为"dropdown-toggle"的 all 元素的单击.这是简单的方法,希望它对您有用.

What the javascript does is that, when you click on an element with the ID "open", it will simulate a click on all elements with the class "dropdown-toggle". This is the easy method, hopefully this will work for you.

这篇关于使用href链接展开多个下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆