mobile.changePage到nextPage?

时间:2011-02-24 22:32:47

标签: java jquery android jquery-mobile

如何更改下面的代码以滑动到下一页/'to:url'而不必为每次更改页面编写脚本?

    <script type="text/javascript">
            $('div').live("swipeleft", function(){
                $.mobile.changePage("#pg02", "slide", false, true);
            });
            $('div').live("swiperight", function(){
                $.mobile.changePage("#pg01", "slide", true, true);
            }); 
    </script>

1 个答案:

答案 0 :(得分:6)

将您的网页重命名为pg1 pg2,...,pg10,前面没有零

<script type="text/javascript">

 window.now=1;

        $('div').live("swipeleft", function(){
            window.now++
            $.mobile.changePage("#pg"+window.now, "slide", false, true);
        });
        $('div').live("swiperight", function(){
            window.now--;
            $.mobile.changePage("#pg"+window.now, "slide", true, true);
        }); 
</script>

您必须添加一些if来保护第一页和最后一页。 您可能还希望将now变量放在不在窗口对象的全局范围内的其他对象中。

相关问题