javascript - jQuery 函数不能与另一个函数一起使用

标签 javascript jquery

我有两个函数可以加载文档就绪。当它们单独运行时,它们工作正常。但是当在同一个文档上调用这两个函数时,准备好 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
});

最佳答案

只传递了一个参数,对 hover 的调用就失败了。添加一个空函数作为第二个参数,它起作用了。

http://jsfiddle.net/FXPhu/19/

关于javascript - jQuery 函数不能与另一个函数一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8344195/

相关文章:

javascript - 表单输入onload替代

javascript - jQuery UI 错误 - f.getClientRects 不是函数

javascript - TypeError : customerFactory. getOrders 不是函数

javascript - 使用 Vuejs 将数据绑定(bind)到自定义下拉列表

jQuery inArray 总是返回 -1

javascript - Jquery ajax post 禁用启用字段并获取响应

javascript - 使用 jQuery 防止回发并运行 OnClick

javascript - 我们可以使用构造的动态 jQuery 选择器吗?

javascript - 使用 jquery 需要在 html 页面中显示 facebook 用户名

javascript - 如何检查所有被选中的一组单选按钮?