简体   繁体   English

jQuery链接淡入/淡出

[英]jquery links fade in/out

I am trying to get my wordpress internal links to appear in a content div, instead of doing a normal page reload. 我试图让我的wordpress内部链接显示在内容div中,而不是进行正常的页面重新加载。 The fade in/out is working correctly, but the div content is not changing. 淡入/淡出功能正常,但div内容未更改。 Firebug is showing no errors, and all internal links are now only adding "#/" to the page link, how would I make sure the link is correctly being added back in with jquery? 萤火未显示任何错误,现在所有的内部连接只添加“#/”页面的链接,我将如何确保链接正确添加回使用jQuery? Thanks in advance, 提前致谢,

PS, I am following the "css-tricks: ajaxing a wordpress theme" video if that helps, 附言:如果有帮助,我正在观看“ css-技巧:压制wordpress主题”视频,

    $(function() {

        $(".home li.home").removeClass("home").addClass("current_page_item");
        var $mainContent = $("#content"),

            URL = '',
            siteURL = "http://" + top.location.host.toString(),
            $internalLinks = $("a[href^='"+siteURL+"']"),
            hash = window.location.hash,
            $el, $allLinks = $("a");

        if (hash) {
            $mainContent.animate({ opacity: "0.1" });
            $(".current_page_item").removeClass("current_page_item");
            $("a[href="+hash+"]").addClass("current_link").parent().addClass("current_page_item");
            hash = hash.substring(1);
            URL = hash + " #content";
            $mainContent.load(URL, function() {
                $mainContent.animate({ opacity: "1" });
            });
        }

        $internalLinks.each(function() {
            $(this).attr("href", "#" + this.pathname);
        }).click(function() {
            $mainContent.animate({ opacity: "0.1" });
            $el = $(this);
            $(".current_page_item").removeClass("current_page_item");
            $allLinks.removeClass("current_link");
            URL = $el.attr("href").substring(1);
            URL = URL + " #content";
            $mainContent.load(URL, function() {
                $el.addClass("current_link").parent().addClass("current_page_item");
                $mainContent.animate({ opacity: "1" });
            });

        });
});

您可以在方法中放入console.log(variableName)并查看firebug中变量的输出是否符合您的期望?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM