Ipad 开关左/开关右不工作
我正在为iPad做演示。我想使用jquery移动库中的swipeleft和swiperight 目前我正在谷歌chrome上测试一切。我确实启用了“模拟触摸屏” 我的问题是:我在控制台中没有收到消息,所以刷卡不起作用 我正在使用的版本: jquery:jquery-2.1.1.js和jquery-mobile:jquery.mobile-1.4.5.jsIpad 开关左/开关右不工作,ipad,jquery-mobile,touch,pug,swipe,Ipad,Jquery Mobile,Touch,Pug,Swipe,我正在为iPad做演示。我想使用jquery移动库中的swipeleft和swiperight 目前我正在谷歌chrome上测试一切。我确实启用了“模拟触摸屏” 我的问题是:我在控制台中没有收到消息,所以刷卡不起作用 我正在使用的版本: jquery:jquery-2.1.1.js和jquery-mobile:jquery.mobile-1.4.5.js $(document).ready(function(){ // Previous/next slide on swipe $('
$(document).ready(function(){
// Previous/next slide on swipe
$('.bg, header').on('swipeleft', function(e){
console.log("swipe left");
});
$('.bg, header').on('swiperight', function(e){
console.log("swipe right");
});
});
我的玉码:
header
h1
| Title
.body
img(src="#{baseUrl}img/bodybg.jpg", alt="body").bg
如果我执行以下操作(绑定和触摸端),我会在控制台中看到“向左滑动/向右滑动”:
$(document).ready(function(){
// Previous/next slide on touchend
$('.bg, header').bind('touchend', function(e){
console.log("touchend");
});
$('.bg, header').bind('touchend', function(e){
console.log("touchend");
});
});
但我不想使用touchend,我想使用swiperight和swipeleft!我在这里遗漏了什么?N更改:
$('.bg, header').on('swipeleft', function(e){
console.log("swipe left");
});
$('.bg, header').on('swiperight', function(e){
console.log("swipe right");
});
致:
通过这种方式,您可以委托滑动事件,无论“.bg,header”是否加载到DOM中
工作示例:请发布您的html标记。您的代码应该可以工作,但使用pagecontainer事件来附加侦听器,而不是使用ready。将
ready
替换为.$(文档)。pagecreate(函数(){给了我未捕获的类型错误:undefined不是函数$(文档)。在(“pagecreate”)上,函数(){
错误消失,但控制台中仍然没有文本,非常奇怪
$(document).on('swipeleft', '.bg, header',function(e){
console.log("swipe left");
});
$(document).on('swiperight', '.bg, header',function(e){
console.log("swipe right");
});