我正在为我的公司创建一个常见问题解答/帮助中心页面。我们试图完成的最后一件事是“热门问题部分”,用户只需点击问题,它就会打开指向问题所在页面的链接,并且手风琴打开正确的部分以显示答案.
$(document).ready(function() {
function close_accordion_section() {
$('.accordion .accordion-section-title').removeClass('active')
.find('img').attr('src', 'http://www.scrubsandbeyond.com/app_themes/scrubsandbeyond/graphics/right.png');
$('.accordion .accordion-section-content').slideUp(300).removeClass('open');
}
$('.accordion-section-title').click(function(e) {
// Grab current anchor value
var currentAttrValue = jQuery(this).attr('href');
if($(this).is('.active')) {
close_accordion_section();
}else {
close_accordion_section();
$(this).find('img').attr('src', 'http://www.scrubsandbeyond.com/app_themes/scrubsandbeyond/graphics/down.png');
// Add active class to section title
$(this).addClass('active');
// Open up the hidden content panel
$('.accordion ' + currentAttrValue).slideDown(300).addClass('open');
}
e.preventDefault();
});
});
这是用于手风琴的 jQuery,完整的工作代码在这里http://jsfiddle.net/gvolkerding/ancu6fgu/3/ 一个例子是,如果我们提出了最重要的问题之一“我如何注册接收促销电子邮件?”,则需要在打开手风琴第 4 部分的情况下加载页面。我们有 8 个单独的页面,上面有问题,所以理想情况下,我所要做的就是在一个链接后面加上一个查询(或您能想到的任何其他方式)以指向正确的页面/问题。我非常感谢提供的任何帮助,谢谢大家。