从外部锚点链接开放的手风琴小组 [英] open accordion panel from external anchor link

查看:116
本文介绍了从外部锚点链接开放的手风琴小组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几周前问过这个问题,但一直没有找到解决方案 - 我是一个代码新手,所以我会尽我所能来更具体。

我有一个带有手风琴的页面 - 它是内置在网站主题中的简短代码。我在外部页面中有链接,这些链接带有可将您带到手风琴页面的锚定标记 - 现在,当点击这些链接时,用户将被带到该术语,但面板不会打开。我希望手风琴小组也能够开放。按原样,所有面板都会在您进入页面时关闭。这是我迄今为止在单击链接到一个链接时删除'closed'类的代码:

  var anchor = window.location.hash.substring(1); 
$('。'+ anchor).removeClass('su-spoiler-closed');

我还没有得到它的工作,也许我没有在右边点?也许jquery一般不在页面上工作?

解决方案

你也可以使用CSS,这对我们的新手来说更容易。 p>

  / * accordion id'unhide * / 
#id:target {
display:block;
}
/ *结束css * /

链接:www.website。 com / page.htm#id


Asked this question a few weeks ago, but have not been able to find a solution - I'm a code novice, so I'll do my best to be more specific.

I have a page with an accordion - it's built-in as a short code that comes with the site theme. I have links in external pages that have anchor tags that take you to the accordion page - right now when those links are clicked, user is taken to the term but the panel does not open. I would like for the panel of the accordion to also open. As-is, all the panels are closed when you get to the page. Here is the code I have so far to remove the 'closed' class when a link w/an anchor is clicked:

var anchor = window.location.hash.substring(1);
$('.' + anchor).removeClass('su-spoiler-closed');

I have not been able to get it to work, perhaps I don't have it in the right spot? Maybe jquery is not working on the page in general?

解决方案

You may also use CSS, it's easier for us novices.

/*accordion ids' unhide*/
    #id:target{
        display:block;
    }
/* end css */

link: www.website.com/page.htm#id

这篇关于从外部锚点链接开放的手风琴小组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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