我有一个简单的jQuery手风琴,在部分标题上带有箭头,当部分关闭时指向下方,当部分处于打开状态时指向该部分。不幸的是,当一个部分被点击时,所有的箭头都将切换到并保持这种状态。我无法弄清楚如何解决这个问题。jQuery Accordion HTML箭头翻转
JQuery的
function AccordionSelectionClickHandler(panelSelector, openCloseSelector)
{
//Get a handle to the list of panels
var allPanels = $(panelSelector);
//Specify the click handler for elements that open or close the accordion panels
$('.arrow').html("↓");
$(openCloseSelector).click(function()
{
//Close all of the panels
allPanels.slideUp();
//Check to see if the slide is already open
if ($(this).parent().next().is(':hidden') == true) {
// if it is not, open it
$(this).parent().next().slideDown('normal');
}
// fix this arrow to select a single arrow
$('.arrow').html("↑");
return false;
});
}
(其中panelSelector
选择手风琴和openCloseSelector
选择面板打开/关闭)
HTML
<dl class="accordion">
<dt><a href="">Panel 1</a>
<span class="arrow"></span></dt>
<dd>Conttent</dd>
<dt><a href="">Panel 2</a>
<span class="arrow"></span></dt>
<dd>Conntent</dd>
<dt><a href="">Panel 3</a>
<span class="arrow"></span></dt>
<dd>Content</dd>
</dl>