平滑滚动 - CSS技巧 - 不起作用

时间:2016-07-11 04:00:33

标签: jquery html5 css3 shopify smooth-scrolling

我刚刚在shopify商店网站上实现了Smooth Scrolling by CSS Tricks的脚本。但它对我不起作用:(

这是平滑滚动的脚本

<script>
 jQuery(function($) {
     $j('a[href*="#"]:not([href="#"])').click(function() {
      if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
        var target = $j(this.hash);
        target = target.length ? target : $j('[name=' + this.hash.slice(1) +']');
        if (target.length) {
          $j('html, body').animate({
            scrollTop: target.offset().top
          }, 1000);
          return false;
        }
      }
    });
   });
 </script> 

这是我的光滑滑块的另一个代码

<script>
 jQuery(function($) {
      $j('.obs_store_wall_slider').slick({
        dots: true,
        infinite: true,
        speed: 500,
        fade: true,
        draggable: false,
        arrows: true,
        autoplay: true,
        autoplaySpeed: 5000,
        pauseOnHover: true,
        cssEase: 'linear'
      });

    $j('.obs_store_wall_banner_slider').slick({
        dots: false,
        infinite: true,
        speed: 500,
        draggable: true,
        arrows: true,
        autoplay: true,
        autoplaySpeed: 5000,
        pauseOnHover: true,
        cssEase: 'linear'
      });
   });
 </script> 

要查看实时操作,请访问my store

1 个答案:

答案 0 :(得分:0)

哇,我不敢相信。由于我的html语法,脚本无法正常工作,我在节ID:D

中添加了一个“#”
相关问题