All.
所有。
I'm working on a long manual, and each section is an accordion that displays when clicked. This is the code for it:
我正在制作一本很长的手册,每个部分都是一个可以在点击时显示的手风琴。这是它的代码:
$(function() {
$( ".accordion" ).accordion({
collapsible: true,
active: false,
heightStyle: "content"
});
});
So in total I have 24 sections (each is an accordion).
所以我总共有24个部分(每部分都是手风琴)。
I'm trying to insert links in one of the sections to point to a different section. This is what they look like right now:
我正在尝试在其中一个部分中插入链接以指向不同的部分。这就是他们现在的样子:
<li><a href="#source1">How to configure Source 1</a></li>
<li><a href="#source2">How to configure Source 2</a></li>
<li><a href="#source3">How to configure Source 3</a></li>
The links currently redirect you to the requested section (identified by id="source1", "source2" and "source3" respectively. However, the accordion doesn't open up. The link takes you to the section, but the accordion remains closed.
链接当前将您重定向到所请求的部分(分别由id =“source1”,“source2”和“source3”标识。但是,手风琴没有打开。链接带您到该部分,但手风琴仍然关闭。
Is there any way I can get that accordion to open up when the link is clicked? I figured I would need an onclick function, but I'm not entirely sure of how to write it.
当点击链接时,有什么方法可以让手风琴打开吗?我想我需要一个onclick函数,但我不完全确定如何编写它。
3 个解决方案
#1
1
Try this :
尝试这个 :
<li><a href="#dropbox" onclick="$('#dropbox').click()">How to configure Dropbox</a></li>
<li><a href="#gdrive" onclick="$('#gdrive').click()">How to configure Google Drive</a></li>
<li><a href="#sserver" onclick="$('#sserver').click()">How to configure SharePoint</a></li>
#2
0
Accordion API not provide any functionality for this.
My try Not sure but i think this will work..
Accordion API不提供任何功能。我的尝试不确定,但我认为这将有效..
$("#goToSecondSection").click(function(){//your link
$("#yourSelector").accordion('option', 'active' , 1);//1,2,3,.. put accordingly
});
#3
0
Sorry, not comfortable with codepen so took all your code to jsfiddle, made changes and it works:
对不起,不熟悉codepen所以你把所有的代码都带到了jsfiddle,做了改动并且它有效:
Relevant section of code is:
相关的代码部分是:
<a href="#dropbox" onclick='$("#dropbox").click();'>How to configure Dropbox3</a>
#1
1
Try this :
尝试这个 :
<li><a href="#dropbox" onclick="$('#dropbox').click()">How to configure Dropbox</a></li>
<li><a href="#gdrive" onclick="$('#gdrive').click()">How to configure Google Drive</a></li>
<li><a href="#sserver" onclick="$('#sserver').click()">How to configure SharePoint</a></li>
#2
0
Accordion API not provide any functionality for this.
My try Not sure but i think this will work..
Accordion API不提供任何功能。我的尝试不确定,但我认为这将有效..
$("#goToSecondSection").click(function(){//your link
$("#yourSelector").accordion('option', 'active' , 1);//1,2,3,.. put accordingly
});
#3
0
Sorry, not comfortable with codepen so took all your code to jsfiddle, made changes and it works:
对不起,不熟悉codepen所以你把所有的代码都带到了jsfiddle,做了改动并且它有效:
Relevant section of code is:
相关的代码部分是:
<a href="#dropbox" onclick='$("#dropbox").click();'>How to configure Dropbox3</a>