0
Я создал простое меню аккордеона. Моя проблема в том, что когда я нажимаю «Folder1», он расширяется, но когда я нажимаю его снова, он должен рухнуть. Я застрял с этим и не смог продолжить какую-либо помощь ..Проблемы с аккордеонным меню
JsFiddle - http://jsfiddle.net/nY2t7/
$(document).ready(function() {
$('#content >li').each(function(i){
hideElements($(this));
});
$('#content').click(function(event) {
$x = $(event.target);
//check if the element is the root node if so then hide all other li's and reveal the current one
if($x.parent().is('ul#content')) {
if($x.is(':visible')) { //check if its already expanded .. if so then collapse and return
$x.find('ul >li').slideUp(300 , function() {
**//return;** does not work
});
}
$('#content ul>li').each(function(i){
collapseElements($(this));
});
}
if($x.is('li'))
$x.find('ul:first > li').slideToggle(300);
});
function collapseElements(el) {
if(el.is(':visible')) {
el.slideUp(300);
}
}
function hideElements(elem) {
elem.find('ul >li').hide();
//$($e >li).hide();
}
});
спасибо alexander, но почему не вызывает возврат после анимации не работает .. $ x.find ('ul> li'). SlideUp (300, function() { ** // return; ** не работает }); – user1184100
@ пользователь1184100, It действительно работа. Вы возвращаетесь из 'function() {}' хотя. Не забудьте отметить как ответ. – Alexander