本文介绍了jQuery 手风琴通过 url 激活?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题脚本部分.

$(document).ready(function(){var show_link = '/hr/resitration';//这是当前的 url.var 手风琴 = $("#accordion");活跃 = ????//如何找到活动网址???手风琴.手风琴({标题:h3",活跃:活跃,自动高度:假});});

在 HTML 部分

<h3><a href="#">仪表板</a></h3><div><ul><li><a href="/dashboard/my" >我的作品</a></li><li><a href="/dashboard/send" >发送作品</a></li>

<h3><a href="#">HR</a></h3><div><ul><li><a href="/hr/resitration?add=true" >添加员工</a></li><li><a href="/hr/resitration" >员工名单</a></li>

  • 配置<ul><li><a href="/hr/schools" >学校</a></li><li><a href="/hr/role" >角色</a></li>
  • 解决方案

    我认为这会让你接近:

    active = Accordion.find("a[href="+show_link+"]").parents("h3");

    Header script section.

    $(document).ready(function(){
        var show_link = '/hr/resitration'; // That is current url.
        var accordion = $("#accordion");
        active = ???? // How to found activ url???
        accordion.accordion({
            header: "h3",
            active: active,
            autoHeight: false
        });
    });
    

    in HTML section

    <div id="accordion">
        <h3><a href="#">Dashboard</a></h3>
        <div>
            <ul>
                <li><a href="/dashboard/my" >My works</a></li>
                <li><a href="/dashboard/send" >Send works</a></li>
            </ul>
        </div>
        <h3><a href="#">HR</a></h3>
        <div>
            <ul>
                <li><a href="/hr/resitration?add=true" >Add Staff</a></li>
                <li><a href="/hr/resitration" >Staff list</a></li>
                <li>Config
                    <ul>
                    <li><a href="/hr/schools" >Schools</a></li>
                    <li><a href="/hr/role" >Roles</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    
    解决方案

    I think this will get you close:

    active = accordion.find("a[href="+show_link+"]").parents("h3");
    

    这篇关于jQuery 手风琴通过 url 激活?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    10-19 23:34