【问题标题】:Skip to the second page (jQuery Mobile)跳到第二页 (jQuery Mobile)
【发布时间】:2012-12-02 17:17:21
【问题描述】:

我的 jquery 移动网站中有三个页面,我希望它跳过左侧页面,以便首先加载第二个页面。

我的小提琴在这里:http://jsfiddle.net/iamthestig/MMwWC/ (您可以用鼠标滑动/滑动浏览页面)

我的代码在这里:

HTML

<div data-role="page" id="left" data-url="left" data-theme="a">LEFT PAGE</div>
<div data-role="page" id="home" data-url="home" data-theme="a">HOME</div>
<div data-role="page" id="right" data-url="right" data-theme="a">RIGHT PAGE</div>

JS

$('div.ui-page').live("swipeleft", function(){
    var nextpage = $(this).next('div[data-role="page"]');
            if (nextpage.length > 0) {
                $.mobile.changePage(nextpage, {transition: "slide", reverse: true, changeHash: false}, true, true);
            }
        });
        $('div.ui-page').live("swiperight", function(){
        var prevpage = $(this).prev('div[data-role="page"]');
        if (prevpage.length > 0) {
        $.mobile.changePage(prevpage, {transition: "slide", reverse: true, changeHash: false}, true, true);
    }
});

CSS

* {
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    background: dimgray;
}

#home {
    background: dodgerblue;
}

#left {
    background: red;
}

#right {
    background: silver;
}

【问题讨论】:

    标签: jquery html css jquery-mobile


    【解决方案1】:

    默认情况下,jQuery mobile 显示 html 文件中的第一页。您可以直接将主页移动到顶部。或者它基本上取决于你从哪里加载这个页面,当通过 href 属性更改到这个页面时意味着你可以做

    <a href="foo.html#home">link</a> 
    

    这将使主页首先加载,其余部分可以通过您的代码或

    $.mobile.changePage("foo.html#home");
    

    这也是一样的。

    【讨论】:

      猜你喜欢
      • 2015-10-07
      • 2014-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多