我没有看到这个问题的任何答案,但我遇到了这个问题:
我制作了一个JQuery菜单UI,它运行得很好。
当您单击列表项中的第一个链接时,列表项应该展开以显示其余链接。
然而!当页面加载时,似乎连接到第一个链接的.toggle()会自动折叠第一个链接。我无法理解。
再次,要重新输入:第一个链接“a.cat”在页面加载时被折叠。它不习惯,我不确定何时,或者是否,我甚至改变它......)。
无论如何,我希望这很清楚。我会定期回来回答问题。
这是JS,因为S.O.需要它:
$("#sidebar ul li a.cat").toggle( function () {
$(this).stop(true).animate({
"color" : "#fff"
});
var growTo = (parseInt($(this).siblings("a.link").length) * nmMenu.linkHeight) + nmMenu.catHeight;
$(this).parent("li").stop(true).animate({
"height" : growTo + "px",
"padding-top" : "5px"
}, function () {
$(this).children("a").stop(true).animate({
"margin-left" : "20px"
});
});
}, function () {
$(this).siblings("a").andSelf().stop(true).animate({
"margin-left" : "0px"
}, function () {
$(this).siblings(" a:first").stop(true).animate({
"margin-bottom" : nmMenu.catMarginBottom + "px",
"color" : nmMenu.linkColor
});
$(this).parent("li").stop(true).animate({
"height" : nmMenu.catHeight + "px"
});
});