繁体   English   中英

jQuery菜单仅在主页上起作用

[英]JQuery Menu Only Working on Homepage

好吧,这是一个非常简单的..甚至是愚蠢的问题。 但是我已经尝试了很长一段时间,以使其正常工作,但没有任何效果。 我有一个带有加号/减号的菜单...该菜单仅在主页上有效,而没有其他功能。 这是代码:

$(document).ready(function(){   
$('.gh-gallink').toggle(
function() {
    $('.gallery_container').animate({
        marginTop: "x",
    }, 1000);
    $('.jquerycssmenu ul li ul').animate({
        marginTop: "x",
    }, 100);
    $('.jquerycssmenu ul li ul li a').animate({
    height: "x",
    }, 100);
    $('#main').animate({
        marginTop: "x",
    }, 1000);
    $(this).text('+');


}, function() {
    $('.gallery_container').animate({
        marginTop: "x",
    }, 1000);
    $('.jquerycssmenu ul li ul').animate({
        marginTop: "x",
    }, 100);
    $('.jquerycssmenu ul li ul li a').animate({
        height: "x",
    }, 100);
    $('#main').animate({
        marginTop: "x",
    }, 1000);
    $(this).text('-');

});
});

菜单工作正常,但仅在主页上可以。 当然,我的实际代码中没有x。 但总的来说,该代码位于我网站的header.php文件中,同样,它仅在我网站的首页上有效。 我尝试将“ $(document)”更改为“ jQuery(Document)”,并且我也停用了所有插件,但是菜单仍然仅在主页上有效。

而且,这是显示切换按钮的html:

<div class="gallerylink">
<a href="#" class="gh-gallink">
    -
</a>
</div>

任何帮助,将不胜感激! :)

编辑:

我按照Chipmunk所说的做了,一个个地摆脱了标题中的每个脚本。 我发现,删除该脚本(在下面列出)后,该脚本会将页面向上滚动到achor,一切正常。 但是,我仍然希望两个脚本同时运行。 这是锚滚动脚本。

// When the Document Object Model is ready
jQuery(document).ready(function(){
    // 'catTopPosition' is the amount of pixels #invisiblebox
    // is from the top of the document
    var catTopPosition = jQuery('#invisiblebox').offset().top;

    // When #scroll is clicked
    jQuery('#scroll, #scrolls').click(function(){
        // Scroll down to 'catTopPosition'
        jQuery('html, body').animate({scrollTop:catTopPosition}, 'slow');
        // Stop the link from acting like a normal anchor link
        return false;
    });
});

因此,当您单击#scrolls或#scroll ..时,它将向上滚动回到anchr“ #invisiblebox”。 我不知道为什么这对我的切换菜单不起作用。 如果有人可以同时运行两个脚本,请告诉我。

暂无
暂无

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

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