使用链接打开 jQuery 手风琴面板(手风琴之外) [英] Open jQuery accordion panel with link (outside of acccordion)
问题描述
对 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:
链接1链接2链接3
|手风琴标题 1 |
|手风琴内容 1 显示|
| Accordion content 1 showing|
|手风琴标题 2 |
|手风琴内容 2 隐藏 |
| Accordion content 2 hidden |
|手风琴标题 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 手风琴面板(手风琴之外)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!