Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 在滚动之间闪烁_Jquery - Fatal编程技术网

Jquery 在滚动之间闪烁

Jquery 在滚动之间闪烁,jquery,Jquery,我一直在尝试建立一个单页面的网站,现在Jquery并不是我的强项 我发现这段代码将滚动到div,我尝试过其他代码,但它们不会滚动 我的问题是,虽然大多数时候它会平滑地滚动,但有时当我点击菜单时,它会在滚动之前闪烁为白色,就像快速重新加载页面或其他什么 知道怎么回事吗 $(document).ready(function(){ $(".contactLink").click(function(){ if ($("#contactForm").

我一直在尝试建立一个单页面的网站,现在Jquery并不是我的强项

我发现这段代码将滚动到div,我尝试过其他代码,但它们不会滚动

我的问题是,虽然大多数时候它会平滑地滚动,但有时当我点击菜单时,它会在滚动之前闪烁为白色,就像快速重新加载页面或其他什么

知道怎么回事吗

$(document).ready(function(){
            $(".contactLink").click(function(){
                if ($("#contactForm").is(":hidden")){
                    $("#contactForm").slideDown("slow");
                }
                else{
                    $("#contactForm").slideUp("slow");
                }
            });
        });
        function closeForm(){
            $("#messageSent").show("slow");
            setTimeout('$("#messageSent").hide();$("#contactForm").slideUp("slow")', 2000);
       }

$(document).ready(function() {
  function filterPath(string) {
    return string
      .replace(/^\//,'')
      .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
      .replace(/\/$/,'');
  }
  $('a[href*=#]').each(function() {
    if ( filterPath(location.pathname) == filterPath(this.pathname)
    && location.hostname == this.hostname
    && this.hash.replace(/#/,'') ) {
      var $targetId = $(this.hash), $targetAnchor = $('[name=' + this.hash.slice(1) +']');
      var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
       if ($target) {
         var targetOffset = $target.offset().top;
         $(this).click(function() {
           $('html, body').animate({scrollTop: targetOffset}, 1000);
           var d = document.createElement("div");
        d.style.height = "101%";
        d.style.overflow = "hidden";
        document.body.appendChild(d);
        window.scrollTo(0,scrollToM);
        setTimeout(function() {
        d.parentNode.removeChild(d);
            }, 10);
           return false;
         });
      }
    }
  });
});