Javascript 移动设备上的Jquery移动刷

Javascript 移动设备上的Jquery移动刷,javascript,jquery,html,css,jquery-mobile,Javascript,Jquery,Html,Css,Jquery Mobile,我对jQuery移动库有一个问题。我想在图像上使用“滑动”事件,用手指在iPhone上滑动图像,但它不起作用。我试着这样使用它: function myEvent() { if ($("#myImageFront").swiperight) { console.log("hey"); $.mobile.changePage("localhost/myOtherPage.php") } } <img class="myImage" id="myImageFront"

我对jQuery移动库有一个问题。我想在图像上使用“滑动”事件,用手指在iPhone上滑动图像,但它不起作用。我试着这样使用它:

function myEvent() {
  if ($("#myImageFront").swiperight) {
    console.log("hey");
    $.mobile.changePage("localhost/myOtherPage.php")
  }
}

<img class="myImage" id="myImageFront" src="myImage.png">
函数myEvent(){
if($(“#myImageFront”).swiperight){
console.log(“嘿”);
$.mobile.changePage(“localhost/myOtherPage.php”)
}
}
我的功能都没用了。

你试过这个吗

$("#myImageFront").on("swiperight", function(event) {
    console.log("Hey");
    //do more stuff
});

你和调试器核对过了吗?它说什么?它什么也没说:'(它们什么都没有。那么要么你没有提供函数的完整代码,要么你无法调试。在你提供的代码中,你永远不会关闭函数,只有
if
语句抱歉,我的错@thanksd我实际上是在我的代码上做的我实际上是在做这个@Johnny Clara$(function(){$(“#myImageFront”).on(“swipe”,swipeHandler());function swipeHandler(event){$(event.target.swipe;}}});但我不知道要在我的图像中添加什么来获得另一个图像。@Kira“$(event.target)是什么意思.swipe;“应该做什么?此外,您还有一个额外的开-关括号。您应该写:。on(“swipe”,swipeHandler);事实上,我正在尝试做同样的事情,当你在亚马逊网站上使用手机时,你可以用手指滑动图像。我遵循本教程:所以swipeHandler实际上是我的第二个可以滑动的功能,但我不知道如何做,但我认为行$(event.target)。一些东西会产生效果。