jQuery Accordion的基本问题
Basic issue with jQuery Accordion
我使用jQuery手风琴作为侧边栏导航。目前我有两个链接,都有"孩子"在他们下面。
这是我的jsFiddle: http://jsfiddle.net/6Eh8C/
你会注意到,当你点击"关于我们",画廊关闭。这不应该发生。只有当我点击'Gallery'时,Gallery才会关闭。
如何解决这个问题?
这是我的jQuery:jQuery(function($) {
$('#accordion > li > a').click(function (e) {
if ($(this).next('ul').length == 0) {
// link is for navigation, do not set up accordion here
return;
}
// link is for accordion pane
//remove all the "Over" class, so that the arrow reset to default
$('#accordion > li > a').not(this).each(function () {
if ($(this).attr('rel')!='') {
$(this).removeClass($(this).attr('rel') + 'Over');
}
$(this).siblings('ul').slideUp("slow");
});
//showhide the selected submenu
$(this).siblings('ul').slideToggle("slow");
//addremove Over class, so that the arrow pointing downup
$(this).toggleClass($(this).attr('rel') + 'Over');
e.preventDefault();
});
$('.slides_item').children('div').css('background','#ededed')
});
非常感谢您的指点:-)
我想你只是想删除一行:
$('#accordion > li > a').not(this).each(function () {
if ($(this).attr('rel')!='') {
$(this).removeClass($(this).attr('rel') + 'Over');
}
// Remove this line, you don't want to slide up other uls.
// $(this).siblings('ul').slideUp("slow");
});
例子: http://jsfiddle.net/6Eh8C/1/
相关文章:
- 在指令控制器中使用$attrs时出现问题
- 将PHP变量传递给jQuery时遇到问题
- Canvas Html5绘图应用程序,移动画布会导致重大问题
- 参数变量出现ngTable指令问题
- 剑道网格jQuery动画()问题
- 我的jQuery插件参数没有正确启动,遇到了问题
- Phonegap-(安卓/iphone)多个图像的图像库出现问题
- TableExport jquery插件:文件名和扩展名问题
- JavaScript Pub/Sub属性访问问题
- JavaScript异步问题
- 如何解决Yii中的页面刷新问题
- Safari(Mac OS)上的jQuery平滑滚动问题
- jqGrid树网格问题
- Bootstrap Accordion崩溃中的问题
- 按钮类切换问题与Bootstrap Accordion&银色条纹
- JQuery Accordion-打开问题
- jQuery Accordion的加减问题
- jQuery Accordion的基本问题
- jQuery Accordion的一个简单问题
- jQuery Accordion-按钮问题