如何在移动设备中显示平滑的视差滚动效果

时间:2014-11-07 11:03:35

标签: jquery

$('a[href^="#"]').on('click',function (e) {
                    e.preventDefault();

                    var target = this.hash;
                    $target = $(target);
                    $target.addClass('active');
                    $('html, body').stop().animate({
                        'scrollTop': $target.offset().top
                        }, 1000, 'swing');
});

HTML代码

                        <div style="position: fixed;font-size:15px">

                                <a href="#header-wrapper">Home</a><br>
                                <a href="#about">About</a>  <br>
                                <a href="#programme">The System</a><br>


                            </div>

<div class="title" id="header-wrapper">Content</div>
<div class="title" id="about">Content</div>

<div class="title" id="programme">Content</div>

我使用此脚本代码来显示视差效果。它在网络上完美运行,但在移动设备中无效。如何使其在移动设备中工作。请帮忙

1 个答案:

答案 0 :(得分:0)

使用tap事件如何:

$('a[href^="#"]').on("tap",function(){
  // Your code
});