2014-09-06 81 views
1

我有兩個頁面:index.html和right.html。基於滑動導航到頁面

需要什麼樣的代碼,通過水平滑動屏幕從index.html轉到right.html?

我使用jQuery Mobile的

$(function() 
{ 
    $(document).on("swipeleft", swipeleftHandler); 

    function swipeleftHandler(event) 
    { 
     // What is the code that should come here? 
     // And how can I design it so index.html slides to left 
     // and right.html comes to the middle? 
    } 
}); 
+0

可能重複[如何在幾個jQuery移動頁面之間滑動?](http://stackoverflow.com/questions/7533772/how-to-swipe-between-several-jquery-mobile-pages) – Emre 2014-09-06 20:07:22

回答

0

您需要預取的頁面,然後更改頁面,你使用jQuery,所以您的代碼將是這樣的:的

$(document).on("swipeleft", "#indexId", function() { 
     $.mobile.loadPage("right.html"); 
     $.mobile.changePage("right.html", { transition: "slide" }); 
    });