我有一個簡單的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>