没有 h3 标签,JQuery 手风琴不起作用 [英] JQuery accordion doesn't work without h3 tags
问题描述
我正在尝试使用 JQuery 制作手风琴,但遇到了一些麻烦.JQuery 网站展示了如何像这样创建您的手风琴内容.
<a href="#">第一个标头</a><div>第一内容</div><a href="#">第二个标题</a><div>第二个内容</div>
当我这样做时,手风琴无法正常工作并且格式有问题.如果我像这样在标题锚点周围放置 h3 标签
<h3><a href="#">第一个标头</a></h3><div>第一内容</div><h3><a href="#">第二个标题</a></h3><div>第二个内容</div>
它有效.有谁知道为什么会这样?它发生在 Firefox 3.5 和 IE 8 中.我今天也刚刚下载了 JQuery 文件.
-谢谢
您必须使用指定的标题选项初始化手风琴:
$('#accordion').accordion({标题:'a'});
您可能还想查看 jQuery Accordion API 以获取更多选项.
I am trying to make an accordion with JQuery and am running into some trouble. The JQuery website shows to create your accordion content like this.
<div id="accordion">
<a href="#">First header</a>
<div>First content</div>
<a href="#">Second header</a>
<div>Second content</div>
</div>
When I do this the accordion doesn't work right and something is wrong with the formatting. If I put h3 tags around the header anchors like so
<div id="accordion">
<h3><a href="#">First header</a></h3>
<div>First content</div>
<h3><a href="#">Second header</a></h3>
<div>Second content</div>
</div>
It works. Does anyone know why this happens? It happens in Firefox 3.5 and IE 8. I also just downloaded the JQuery files today.
-Thanks
You must initialize the accordion with the header option specified:
$('#accordion').accordion({
header: 'a'
});
You also might want to check out the jQuery Accordion API for more options.
这篇关于没有 h3 标签,JQuery 手风琴不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!