[英]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.