一次打开一个选项卡 [英] Open one tab at a time in accordion
本文介绍了一次打开一个选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个手风琴,它的工作绝对正常,但我需要的是一次只打开一个选项卡,意味着当一个选项卡打开,然后另一个选项卡应该关闭。
I have a accordion which is working absolutely fine but what I need is to open only one tab at a time, means when one tab is opened then another tab should be closed.
目前您可以看到我们可以通过点击标签页链接打开所有标签页。
Currently you can see that we can open all the tabs by clicking on tab links.
此处的代码
$("#accordion > li > span").click(function() {
$(this).siblings("div").slideToggle(250);
$(this).toggleClass("active");
});
这是 小提琴
Here is the Fiddle
推荐答案
a href =http://jsfiddle.net/RX5J6/5/ =nofollow> LIVE DEMO
$("#accordion > li > span").click(function() {
$(this).closest('li').siblings().find('span').removeClass('active').next('div').slideUp(250);
$(this).toggleClass("active").next('div').slideToggle(250);
});
或类似:
< a href =http://jsfiddle.net/RX5J6/6/ =nofollow> LIVE DEMO
$("#accordion > li > span").click(function() {
$(this).toggleClass("active").next('div').slideToggle(250)
.closest('li').siblings().find('span').removeClass('active').next('div').slideUp(250);
});
这篇关于一次打开一个选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文