jquery 手风琴 - 一直隐藏父元素?
好吧,我通过在结束标签后添加来解决了我原来的问题,但现在这些链接无法打开?
所以,基本上,在下面的 html 中,我尝试只打开服务部分,但我希望 h3 标签打开这些链接...
<div id="sp-accordion">
<h3><a href="/?page_id=3">Home</a></h3><div></div>
<h3><a href="/?page_id=2">About Us</a></h3><div></div>
<h3><a href="#"> Services</a></h3>
<div>
<p><a href="/?page_id=16">S1</a></p>
<p><a href="/?page_id=14">S2</a></p>
<p><a href="/?page_id=20">S3</a></p>
</div>
<h3><a href="/?page_id=9">Contact Us</a></h3><div></div>
<h3><a href="/?page_id=5">Tips</a></h3><div></div>
<h3><a href="/?page_id=108">Jobs</a></h3><div></div>
<h3><a href="/?page_id=131">Newsletter</a></h3><div></div>
</div>
手风琴可以工作,因为当您单击 h3 标签时,容器滑开,但是,当它滑开时,它隐藏了前面的 h3。所以,在下面的 html 中,当我单击“服务”时,它下面的 div 会滑动打开,但是“关于我们”h3 消失了...
这是 html:
<div id="sp-accordion">
<h3><a href="/?page_id=3">Home</a></h3>
<h3><a href="/?page_id=2">About Us</a></h3>
<h3><a href="#"> Services</a></h3>
<div>
<p><a href="/?page_id=16">S1</a></p>
<p><a href="/?page_id=14">S2</a></p>
<p><a href="/?page_id=20">S3</a></p>
</div>
<h3><a href="/?page_id=9">Contact Us</a></h3>
<h3><a href="/?page_id=5">Tips</a></h3>
<h3><a href="/?page_id=108">Jobs</a></h3>
<h3><a href="/?page_id=131">Newsletter</a></h3>
</div>
我正在使用 jquery ui,所以 jquery 就是这样:
$(document).ready(function() {
$("#sp-accordion").accordion({autoHeight:false});
});
Well, I fixed my original question by including after the closing tags, but now, those links won't open?
So, basically, in the html below, I'm trying so that only the services section slides open, but I want the h3 tags to open those links...
<div id="sp-accordion">
<h3><a href="/?page_id=3">Home</a></h3><div></div>
<h3><a href="/?page_id=2">About Us</a></h3><div></div>
<h3><a href="#"> Services</a></h3>
<div>
<p><a href="/?page_id=16">S1</a></p>
<p><a href="/?page_id=14">S2</a></p>
<p><a href="/?page_id=20">S3</a></p>
</div>
<h3><a href="/?page_id=9">Contact Us</a></h3><div></div>
<h3><a href="/?page_id=5">Tips</a></h3><div></div>
<h3><a href="/?page_id=108">Jobs</a></h3><div></div>
<h3><a href="/?page_id=131">Newsletter</a></h3><div></div>
</div>
The accordion works, insomuch that when you click on the h3 tag, the container slides open, however, when it slides open, it hides the h3 before it. So, in the html below, when I click on "Services" the div beneath it slides open, but the About Us h3 disappears...
This is the html:
<div id="sp-accordion">
<h3><a href="/?page_id=3">Home</a></h3>
<h3><a href="/?page_id=2">About Us</a></h3>
<h3><a href="#"> Services</a></h3>
<div>
<p><a href="/?page_id=16">S1</a></p>
<p><a href="/?page_id=14">S2</a></p>
<p><a href="/?page_id=20">S3</a></p>
</div>
<h3><a href="/?page_id=9">Contact Us</a></h3>
<h3><a href="/?page_id=5">Tips</a></h3>
<h3><a href="/?page_id=108">Jobs</a></h3>
<h3><a href="/?page_id=131">Newsletter</a></h3>
</div>
I'm using jquery ui, so the jquery is just this:
$(document).ready(function() {
$("#sp-accordion").accordion({autoHeight:false});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的内容中有链接。请尝试
“如果您在手风琴内容中有链接并使用 a 元素作为标题,请向它们添加一个类并将其用作标题,例如 header: 'a.header'。”
这是来自 JQuery UI doco。
希望这有帮助:)
You have links inside your content. Please try this
"If you have links inside the accordion content and use a-elements as headers, add a class to them and use that as the header, eg. header: 'a.header'."
This is from the JQuery UI doco.
Hope this helps :)