问题描述
对jQuery还是新手!
Still new to jQuery!
我有一个使用jQuery UI 1.10.1构建的手风琴。这很基本;默认情况下,第一项显示,其他项被隐藏,直到单击为止。我想使用jQuery手风琴上方的链接来单击某个特定的手风琴面板。看起来像这样:
I have an accordion that was built with the jQuery UI 1.10.1. It's pretty basic; the first item is showing by default, and the others are hidden until clicked on. I'd like to use links that exist above a jQuery accordion to open a certain accordion panel when clicked. It looks something like this:
Link1 Link2 Link3
Link1 Link2 Link3
|手风琴标题1 |
| Accordion Header 1 |
|手风琴内容1显示|
| Accordion content 1 showing|
|手风琴标题2 |
| Accordion Header 2 |
|手风琴内容2隐藏|
| Accordion content 2 hidden |
|手风琴标题3 |
| Accordion Header 3 |
|隐藏了手风琴内容3 |
| Accordion content 3 hidden |
..因此,当您单击 Link2时,它会隐藏手风琴内容1并显示手风琴内容2。
..so that when you click on "Link2", it hides Accordion content 1 and shows Accordion content 2.
我已经搜索了该站点,但没有一个合适的答案。
I've searched the site and none of the answers seemed fitting.
谢谢
推荐答案
您可能会使用其他方法将按钮链接到标题部分,我只是使用了按钮的id。
You could probably use a different method for linking the button to the header sections, I just used the id from the button.
但是本质上是:
$( "#accordion" ).accordion();
$('.section-button').on('click', function(){
var header = $('#accordion').find('.' + this.id);
header.click();
});
这篇关于打开带有链接的jQuery手风琴面板(不在acccordion中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!