Jquery 切换最终隐藏了单击的元素而不是运行函数

Jquery toggle ends up hiding the clicked element instead of running functions

本文关键字:元素 函数 运行 单击 隐藏 Jquery      更新时间:2023-09-26

我对jquery很陌生,我很坚持这个。 我知道这将是一件愚蠢的事情,但我已经为此打破了很长时间。

我想在 2 个或更多函数之间切换以动画化 de 特定的div 在站点中。但我最终使菜单项不可见。

提前感谢!

$(document).ready(function() {
    $("#menu-item-13 a").toggle(
    function () {
        $("#branding").animate({left:416,top:176}).css('z-index', 12);
        $("#a").animate({left:659,top:175});
        $("#post-2").animate({left:160,top:177});
        $("#post-48").animate({left:402,top:324});
        $("nav").animate({left:174,top:56});
        $("#post-30").animate({left:403,top:842});
        $("#post-1").animate({left:902,top:528});
        $("#post-60").animate({left:903,top:55});
        },
    function () {
        $("#branding").animate({left:545,top:176}).css('z-index', 12);
        $("#a").animate({left:84,top:175});
        $("#post-2").animate({left:160,top:85});
        $("#post-48").animate({left:45,top:324});
        $("nav").animate({left:174,top:56});
        $("#post-30").animate({left:403,top:842});
        $("#post-1").animate({left:902,top:528});
        $("#post-60").animate({left:903,top:55});
        });
});

这个版本的 toggle( .toggle(function{}, function(){}) ) 在 jQuery 版本 1.9 中被删除,所以如果你使用的是 1.9>版本,那么调用 toggle 将切换元素的显示。

如果要重新添加对已删除功能的支持,可以包含升级说明中指定的迁移插件