开发者社区 问答 正文

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

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

展开
收起
杨冬芳 2016-06-23 15:59:39 2077 分享 版权
1 条回答
写回答
取消 提交回答
  • IT从业


    <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>


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

    2019-07-17 19:46:29
    赞同 展开评论
问答分类:
问答地址: