簡體   English   中英

mobile.changePage到nextPage?

[英]mobile.changePage to nextPage?

如何更改下面的代碼以滑動到下一頁/“ 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>

將頁面重命名為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變量放在其他對象中,而不放在window對象的全局范圍內。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM