平滑滚动后关闭模态达到锚

问题描述:

我正在使用Bootstrap,并且常规导航当前使用平滑滚动脚本进入页面的各个部分。平滑滚动后关闭模态达到锚

对于手机,我有一个全屏导航模式,一旦你点击汉堡图标就会打开。它也将使用平滑滚动,但是我似乎无法让模式关闭,只要您点击菜单中的链接并将其带到该部分。

脚本

$(function() { 
    $('a[href*=#]').click(function() { 
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
     || location.hostname == this.hostname) { 

     var target = $(this.hash); 
     target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); 
     if (target.length) { 
     $('html,body').animate({ 
      scrollTop: target.offset().top 
     }, 1000); 
     return false; 
     } 
    } 
    }); 
$('#myModal').modal('hide'); 
}); 

$('#myModal').hide(); 

也许

$('#myModal').remove(); 
+0

我想通了错误。我刚添加它在菜单滚动后立即触发。所以就在退货声明之前。 – peyton98