首页 > 关于js模拟移动端上滑问题。

关于js模拟移动端上滑问题。

我做一个移动端上滑页,现在需要单击一下也可以滑动到下一页,请问js点击一下也可以模拟手机上滑吗?该怎么写呢?谢谢!


fullPage.js


用swiper.js


把手机上滑的代码抽取成一个函数,让两个事件共同调用。


<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <script src="js/jquery-1.11.3.js"></script>
    <title></title>
    <style>
    *{margin:0px;padding:0px;}
    body{overflow:hidden;}
    </style>
    <script>
    $(function(){
        var h=$(window).height();
        $(".main").css("height",2*h+"px");
        $(".prev").css("height",h+"px");
        $(".next").css("height",h+"px");
        $("#next").click(function(){
            $(".main").animate({"margin-top":-h+"px"},1000);
        });
    });
    </script>
</head>
<body>
<div class="main">    
    <div class="prev" style="background:red">
        <p id="next">下一个</p>
    </div>
    <div class="next"  style="background:blue">
        
    </div>
</div>
</body>

</html>
直接这样行 应该就成吧 我刚在手机上测试可以

【热门文章】
【热门文章】