Jquery 链接不响应单击事件

Jquery 链接不响应单击事件,jquery,Jquery,添加以下脚本后,链接(如 停止工作。它们不再响应单击事件。 有人能帮我解决这个问题吗 $(document).ready( function() { $(".show").click(function() { $(".show").hide(); $(".hide").show(); $("#cpks-table").fadeIn(); }); }); $(document).ready( function() { $(

添加以下脚本后,链接(如
停止工作。它们不再响应单击事件。

有人能帮我解决这个问题吗

$(document).ready(
function() {
    $(".show").click(function() {
        $(".show").hide();
        $(".hide").show();
        $("#cpks-table").fadeIn();
    });
});

$(document).ready(
function() {
     $(".hide").click(function() {
        $(".show").show();
        $(".hide").hide();
        $("#cpks-table").fadeOut();
    });

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

    $( ".tggl" ).click(function() {
         $(".show").fadeToggle();
        $(".hide").fadeToggle();
    $( "#cpks-table" ).fadeToggle();
    }); 

$(document).on('click', 'a', function(event){
event.preventDefault();

$('html, body').animate({
    scrollTop: $( $.attr(this, 'href') ).offset().top-100
}, 500);
});

});

您好,您正在通过阻止链接的默认行为

event.preventDefault();
动画完成后,你应该通过Javascript打开链接

window.open($.attr(this, 'href'))
所以你应该写一些

$(document).on('click', 'a', function(event){
    event.preventDefault(); //preventing default behavior of link click
    //do what you need
    var self = this;
    $('html, body').animate({
        scrollTop: $( $.attr(self, 'href') ).offset().top-100
    }, 500, function() {
        //redirect user where intended
        window.location.href = $.attr(self, 'href');
    });
});

您需要更多的线路,如:

 $(document).on('click', 'a', function(event){

    event.preventDefault(); //preventing default behavior of link click
    //do what you need
    $('html, body').animate({
        scrollTop: $( $.attr(this, 'href') ).offset().top-100
    }, 500);
   //redirect user where intended
    window.location.href=$(this).attr('href');

    });

感谢您的提示,删除这些行将再次打开链接,但我的
…scrollTop:$($.attr(this,'href')).offset()将被删除.top-100…
不再工作。我不建议删除这一行。我建议,在动画完成后手动打开链接。是的,但单击链接时链接不会打开。这是正常的,如果在阻止行之后打开,这应该是意外行为。如果没有
preventDefault()平滑滚动动画,是否有可能
什么?