简体   繁体   English

显示“隐藏Scollto菜单”不会触发“普通链接”吗?

[英]Show Hide Scollto Menu won't fire Normal Links?

Not sure what I'm doing wrong here. 不知道我在做什么错。 But when I test this menu out the absolute links wont trigger? 但是,当我测试此菜单时,绝对链接不会触发吗? I'm using a jquery script to trigger the show/hide functionality of the menu and simultaneously adds and removes specific class names from a couple divs. 我正在使用一个jquery脚本来触发菜单的显示/隐藏功能,并同时从几个div中添加和删除特定的类名。

What I'd like to do is make it so absolute url's work for going to outside pages. 我想做的是使它成为转到外部页面的绝对URL。 I'm using my own internal pages with absolute path for testing. 我正在使用自己的内部页面进行绝对测试。

<!-- START SHOW HIDE DROP MENU -->
<div id="mobileMenu" class="list-nav menu_hide"><!-- add class of menu_show, and simultaneously add a class of show-lockscreen to the screen class below. -->
    <ul>
        <li><a href="http://jonnyb.org/index.php" id="item-1">Home Screen</a></li>
        <li><a href="http://jonnyb.org/index.php">Web Focused</a>
            <ul>
                <li><a href="#websummary" class="scroll">Summary</a></li>
                <li><a href="#portfolio" class="scroll">Portfolio</a></li>
                <li><a href="#weboverview" class="scroll">Overview</a></li>
                <li><a href="#webskills" class="scroll">Skills</a></li>
            </ul>
        </li>
        <li><a href="http://jonnyb.org/music.php">Music Focused</a>
            <ul>
                <li><a href="#musicsummary" class="scroll">Summary</a></li>
                <li><a href="#music" class="scroll">Music</a></li>
                <li><a href="#video" class="scroll">Video</a></li>
                <li><a href="" class="scroll">Photos (coming soon)</a></li>
                <li><a href="#musicoverview" class="scroll">Overview</a></li>
                <li><a href="#musicskills" class="scroll">Skills</a></li>
            </ul>
        </li>
        <li><a href="#connect" class="scroll">Connect</a></li>
    </ul>
</div>
<!-- END SHOW HIDE DROP MENU -->

Here is the simple JS I have implemented for the show/hide & scroll & a few other functions used. 这是我为显示/隐藏和滚动以及其他一些使用的功能实现的简单JS。

/* ============================================================
SCROLL TO
=============================================================== */

$(document).ready(function(){ 
    // show and hide mobile menu
    $('a#triggerMobileMenu, div#mobileMenu li a').on('click', function(evt){
        evt.preventDefault();
        $('#mobileMenu').toggleClass('menu_hide menu_show');
        $('#mobileScreen').toggleClass('lockscreen_off lockscreen_on');
    });
}); 


/*global $:false */
$(document).ready(function(){"use strict";

    $(".scroll").click(function(event){

        var full_url = this.href;
        var parts = full_url.split("#");
        var trgt = parts[1];
        var target_offset = $("#"+trgt).offset();
        var target_top = target_offset.top - 75;

        $('html, body').animate({scrollTop:target_top}, 1500);

    });
}); 


$(document).ready(function(){ 

     $(window).scroll(function(){
         if ($(this).scrollTop() > 100) {
             $('.scrollup').fadeIn();
         } else {
             $('.scrollup').fadeOut();
         }
     }); 

     $('.scrollup').click(function(){
         $("html, body").animate({ scrollTop: 0 }, 600);
         return false;
     });

 });


$(document).ready(function() {

    // the portfolio items
    var $container = $('#isotope-container');
    $container.isotope({
        layoutMode: 'masonry',
        masonry: {
            columnWidth: 127,
            gutter: 16
        },

        filter: '*',
        animationOptions: {
            duration: 750,
            easing: 'linear',
            queue: false
        }
    });


    // filter portfolio items
    $('#isotope-options a').click(function(){
        $('#isotope-options .current').removeClass('current');
        $(this).addClass('current');

        var selector = $(this).attr('data-filter');
        $container.isotope({
            filter: selector,
            animationOptions: {
                duration: 750,
                easing: 'linear',
                queue: false
            }
         });
         return false;
    });

});


$(document).ready(function() {
    $(".fancybox").fancybox();
});


$(document).ready(function() {
    $("img.lazy").lazyload({
        effect : "fadeIn"
    });
});


$(document).ready(function () {
    //call this first so we start out with the correct visibility depending on the selected form values
    toggleFields();

    //this will call our toggleFields function every time the selection value field changes
    $("#projecttype").change(function () {
        toggleFields();
    });
});

您正在传递的事件上调用preventDefault()。这将阻止锚标记的默认功能。

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

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