没有h3标签,jQuery手风琴无法正常工作 [英] JQuery accordion doesn't work without h3 tags

查看:76
本文介绍了没有h3标签,jQuery手风琴无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JQuery折叠手风琴,并且遇到了一些麻烦。

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>

当我这样做时,手风琴工作不正常,格式有些问题。如果我像这样在标题锚周围放置h3标签

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>

它有效。有谁知道为什么会这样吗?它发生在Firefox 3.5和IE 8中。我今天也刚刚下载了JQuery文件。

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.

-谢谢

推荐答案

必须使用指定的标头选项初始化手风琴:

You must initialize the accordion with the header option specified:

$('#accordion').accordion({ 
  header: 'a' 
});

您可能还想查看 jQuery手风琴API 获取更多选项。

You also might want to check out the jQuery Accordion API for more options.

这篇关于没有h3标签,jQuery手风琴无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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