根据当前网址打开手风琴

问题描述

所以我有一个手风琴,我正在使用下面的基本骨架。手风琴效果很好,但我们希望当有人单击其中一个链接并重新加载页面时,该部分保持展开状态。诚然,JavaScript 对我来说非常陌生,我正在寻求建议。

手风琴代码很好用 var $title = $('.js-title'); var copy = '.js-copy';

$title.click(function () {
$(this).next(copy).slidetoggle();
$(this).parent().siblings().children().next().slideUp();
return false;
    

我想弄清楚如何检查 URL,然后打开与我在下面开始的链接相关联的父级。

$(document).ready(function() {
var link = window.location.href; 
// open accordion
jQuery(link).slideDown().addClass('open').prev('.js-copy').addClass('active');
});
});



<div class="sectiontitle js-title">Getting Started</div>
<div class="category js-copy">
<a href="index.PHP?act=Pages&pid=9#rules">site rules</a>
<a href="index.PHP?act=Pages&pid=10#charcreate">Character creation</a>
<a href="index.PHP?act=Pages&pid=33#resources">resources</a>
</div>
</div>
          
<div class="accordion">
<div class="sectiontitle js-title">Site information</div>
<div class="category accordion__copy js-copy">
<a href="index.PHP?act=Pages&pid=12#setting">link name</a>
<a href="index.PHP?act=Pages&pid=11#siteinfo">link name</a>
<a href="index.PHP?act=Pages&pid=13#encyclopedia">link name</a>
</div>
</div>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)