Jquery手风琴,下一个和上一个向导,如何获取上一个和下一个部分?
我有一个 Jquery 手风琴,工作正常。单击相应标题时,部分会展开/折叠。但我想添加功能,以便当我单击“下一个”按钮时,它会打开下一部分,单击“上一个”按钮会将我带回上一个部分。
这已在此页面上完成 http://jquery.bassistance.de/ Accordion/demo/?p=1.1.2 (最后一个示例)但不确定如何在我的情况下实现相同的效果。
有什么建议请。
谢谢
更新:我如何获得手风琴的上一节或下一节?
<script type="text/javascript">
$("#accordion").accordion({
header: "h3.header"
, autoHeight: false
, collapsible: true
});
</script>
<div id="accordion">
<h3 class="header">Section 1</h3>
<div> content 1 .. content 1 .. content 1 .. content 1 ..
<input class="next" type="button" value="next"/>
</div>
<h3 class="header">Section 2</h3>
<div> content 2 .. content 2 .. content 2 .. content 2 ..
<input class="previous" type="button" value="previous"/>
<input class="next" type="button" value="next"/>
</div>
<h3 class="header">Section 3</h3>
<div> content 3 .. content 3 .. content 3 .. content 3 ..
<input class="previous" type="button" value="previous"/>
</div>
</div>
I have a Jquery accordion which works fine. Sections get expanded/collapsed when clicked on respective headers. But I want to add the functionality so that when I click on "next" button it opens up the next section and clicking "Previous" button takes me back to previous section.
This has been done on this page http://jquery.bassistance.de/accordion/demo/?p=1.1.2 (last example) but not sure how do I implement the same in my case.
Any suggestions please.
Thanks
UPDATE: How do I get previous or next section of the accordion?
<script type="text/javascript">
$("#accordion").accordion({
header: "h3.header"
, autoHeight: false
, collapsible: true
});
</script>
<div id="accordion">
<h3 class="header">Section 1</h3>
<div> content 1 .. content 1 .. content 1 .. content 1 ..
<input class="next" type="button" value="next"/>
</div>
<h3 class="header">Section 2</h3>
<div> content 2 .. content 2 .. content 2 .. content 2 ..
<input class="previous" type="button" value="previous"/>
<input class="next" type="button" value="next"/>
</div>
<h3 class="header">Section 3</h3>
<div> content 3 .. content 3 .. content 3 .. content 3 ..
<input class="previous" type="button" value="previous"/>
</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我能够让它发挥作用。尝试一下,它适用于 jQuery 1.6 和 jQuery UI 1.8:
HTML:
jQuery:
I was able to get it to work. Give this a shot, it works with jQuery 1.6 and jQuery UI 1.8:
HTML:
jQuery:
将其添加到您的 jQuery 文件中。它添加了一个函数 $("#accordion").accordion("next") 和一个选项“loopOnNext”(默认 false),以强制它在结束时返回到顶部框。
Add this to your jQuery files. It adds a function $("#accordion").accordion("next") and an option, "loopOnNext" (default false) to force it to return to the top box when it's at the end.
我有一个类似的问题并使用:
在每个手风琴窗格上。它位于第二个窗格中,可让您返回到第一个窗格(索引为 0)或前进到第三个窗格(索引为 2)。
I had a similar problem and used:
on each accordion pane. This is on the 2nd pane and brings you back to the first (index of 0) or forward to the third (index of 2).
您是否尝试过像示例中那样做?
Have you tried to do just like in example?
我正在寻找同一问题的解决方案并提出了这个(我正在使用 jQuery 1.4.2 和 jQuery UI 1.8.1):
这是脚本:
I was looking for a solution to the same problem and come up with this (I'm working with jQuery 1.4.2 and jQuery UI 1.8.1):
And this is the script:
试试这个:
其中
:button
是上一个和下一个按钮,wizard
是你的 jQuery 手风琴。省略所有其他代码。看看这是否有效。
请留下反馈,谢谢。
try this:
Where
:button
are the prev and next buttons, andwizard
is your jQuery accordion.Leave out all the other code. See if this works.
Please leave feedback, thanks.