我在StackOverlow上找不到我遇到的问题的答案 . 我引用了Custom Accordion with arrows来设置初始手风琴 .
我很难根据隐藏的div是显示还是隐藏来改变图像图标 .
-
在初始加载时,第一个(div class =“sectionContent”)应该是一个带有上箭头图像的Open - 我无法将箭头图标更改为上箭头 .
-
节 Headers 应切换隐藏内容并更改箭头图像 . - 我无法完成这项工作 . 当我单击其隐藏内容可见的节 Headers 时,箭头图像不会更改 .
var headers = $('.sectionDown a');
var contentAreas = $('.sectionContent').hide();
var firstContentAreas = $('.sectionContent').hide().first().show();
headers.click(function(e) {
e.preventDefault();
var panel = $(this).parent('div').next('div');
var isOpen = panel.is(':visible');
$('.sectionDown a').first().addClass('close');
// open or close as necessary
contentAreas.slideUp();
panel[isOpen? 'slideUp': 'slideDown']()
// trigger the correct custom event
.trigger(isOpen? 'hide': 'show');
$('.sectionDown a').removeClass('close');
$(this).removeClass('close').addClass('close');
// stop the link from causing a pagescroll
return false;
});
1 回答
这应该可以解决您的问题 .
http://jsfiddle.net/GHLM9/