2 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>
Run Code Online (Sandbox Code Playgroud)
将页面重命名为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>
Run Code Online (Sandbox Code Playgroud)
你必须添加一些ifs来保护第一页和最后一页.您可能还希望将now变量放在某个其他对象中,而不是在window对象的全局范围内.
| 归档时间: |
|
| 查看次数: |
2772 次 |
| 最近记录: |