0
我正在为学校建设手风琴,我觉得它应该可以工作。我知道我有一切,直到if else语句。任何建议赞赏手风琴故障我在制作
$(document).ready(function() {
//
// Set up a click event handler for clicked <li>
//
$('#accordion li').click(function() {
// find first ul that is a child of this (the clicked <li>)
var $nextUL = $(this).children('ul:first-child');
// Select all siblings of the clicked <li> and then
// select any direct children <ul>'s
// that are visible - this is so we can close any visible
// <ul> before opening the <ul> for the clicked <li>
var $visibleSiblings = $(this).siblings().children('ul:visible');
// If any other <ul>s are visible, slide the visible <ul>
// up and then, after the slide up is complete, slide down
// the clicked <li>'s <ul> into view
if ($visibleSiblings.length > 0) {
$visibleSiblings.slideUp('normal', function() {
$nextUL.fadeIn('normal');
});
} else {
// either no <ul>s were open (open the clicked item)
// or the user clicked on the currently open one so close it
$nextUL.slideToggle('normal');
}
});
});
您有任何HTML可以使用它,因此我们可以测试吗? – mkaatman 2015-03-03 01:50:20
在逻辑上似乎没有任何不规则。但对于手风琴,我们预计'fadeIn()'是'slideDown()'。什么是/不是在做什么?在jsfiddle.net中的演示将有所帮助。 – charlietfl 2015-03-03 01:51:15
我从来没有用过jsfiddle,但这里是一个镜头。 http://jsfiddle.net/m6fo2z4y/1/ – cmey5084 2015-03-03 01:55:02