我在我的項目中與jquery移動工作,而我試圖做,而不是使用刷卡效果,使用兩個按鈕切換到下一個和以前的數據-role =頁。jQuery的移動更改爲下一個和以前的數據 - 角色=頁
IM與該JavaScript嘗試,但我不知道爲什麼不工作
THX的任何幫助。
HTML:
<div data-role="page" id="p1">
<div data-role="header" data-theme="a" data-position="fixed" data-id="footer" data-fullscreen="true">
<a href="#prvbutton" id="goback" data-icon="arrow-l" style="margin-right:340px" class="ui-btn-right" data-inline="true" data-iconpos="notext" data-direction="reverse">Página Anterior</a>
<a href="#nextbutton" id="goforward" data-icon="arrow-r" style="margin-right:290px" class="ui-btn-right" data-inline="true" data-iconpos="notext" data-direction="reverse">Próxima Página</a>
</div>
<div data-role="content">
.....something......
</div>
</div>
<div data-role="page" id="p2">
<div data-role="header" data-theme="a" data-position="fixed" data-id="footer" data-fullscreen="true">
<a href="#prvbutton" data-icon="arrow-l" style="margin-right:340px" class="ui-btn-right" data-inline="true" data-iconpos="notext" data-direction="reverse">Página Anterior</a>
<a href="#nextbutton" data-icon="arrow-r" style="margin-right:290px" class="ui-btn-right" data-inline="true" data-iconpos="notext" data-direction="reverse">Próxima Página</a>
</div>
<div data-role="content">
.....something......
</div>
</div>
等等........
的Javascript:
$("#nextbutton").on('click', '#goforward', function() {
var next = '#' + $.mobile.activePage.next('[data-role=page]')[0].id;
$.mobile.changePage(next, {
transition: 'slide'
});
});
// Previous page
$("#prvbutton").on('click', '#goback', function() {
var prev = '#' + $.mobile.activePage.prev('[data-role=page]')[0].id;
$.mobile.changePage(prev, {
transition: 'slide',
reverse: true
});
});
沒有ID'nextbutton'或'prvbutton',要麼改變你的HTML或JavaScript中選擇。 –
另外我不能識別'prev'和'next'類 –
@Kilian:thx的提示...我爲按鈕添加了一個id並更新了上面的代碼...看一看pls – user2232273