我有两个函数可以加载文档就绪。它们单独运行时工作正常。但是当两个函数都在同一个文件上调用就绪js。其中一个(第二个)不起作用。请帮忙。文件设置在: http://jsfiddle.net/rexonms/FXPhu/15/
以下基本代码在文档就绪时调用。它调用jQuery 1.2.6 - 它是一个封闭的CMS,我不能改变jQuery的版本:
// Sidebar Accordion Nav
$("#linkListSub3 li li").hide();
$("#linkListSub3 li").hover(function() {
if ($("li", this).is(":hidden")) {
$("#linkListSub3 li li").next().slideUp();
$("li", this).next().slideDown();
}
return false;
});
//Hide And show Toggle Bar animation
$(".toggleContainer").hide(); //Hide (Collapse) the toggle containers on load
//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
$("a.trigger").click(function() {
$(this).toggleClass("active").next().slideToggle("slow");
return false; //Prevent the browser jump to the link anchor
});
答案 0 :(得分:8)
对hover
的调用正在爆发,只传递了一个参数。添加一个空函数作为第二个参数,它可以工作。
答案 1 :(得分:0)
您只将一个功能传递给.hover()
。直到jQuery 1.4才添加该语法。您需要将2个函数传递给hover
,或者将hover
更改为mouseover
或mouseout
(具体取决于您要执行的操作)。