第一个加减号有效...在页面加载时,ul被取消隐藏,图标为减号。其他的也是正确的,并且是加号,但是这些是隐藏的(因此看起来像开放和封闭的手风琴菜单)。
为什么我要点击其他人两次?这会破坏正减去同步。
JS小提琴链接可能有所帮助,但我不知道:http://jsfiddle.net/Ft6tg/
HTML with a ul with sub uls exists in this system... this is implied.
JS
//navigation.js file
//opens the accordion on page load
//I made it so that the menu where that link is, is open on page load
//a function
// title for open accordion ul now gets a minus sign put beside it (this is an h2 within an li)
$(subSectionLi).find('#toggle-icon').html(("<i class='fa fa-minus-circle'></i>"));
//end of function
//dropdown.js file
//does the toggles on that page, and selects the font awesome circle-plus minus
$("#aside").on('click','div span h2',function(event){
var el = $(this).parent().parent().parent().find('#dropdown');
if ( !el.is(':animated') ) {
$(el).slideToggle('slow');
event.preventDefault();
var accordion = $(this).children('span#toggle-icon');
var menu = $("#dropdown.dropMenu");
accordion.toggleClass("closed");
if ($(accordion).hasClass("closed")){
// change plus/minus icon
accordion.html("<i class='fa fa-plus-circle'></i>");
} else {
accordion.html("<i class='fa fa-minus-circle'></i>");
}
}
});