我在 iPad 上有一个页面,在实现等效的鼠标移出行为时遇到一些问题。
所以我有:
- 在我的页面上,点击(或更确切地说触摸)时有一个复选框,我想显示错误消息
- 点击/触摸除 errorMsg 之外的任何内容时,我想隐藏 errorMsg
下面是我编写的代码;
$(document).bind("touchstart",function(e){
if(e.target.id != "checkbox_err")
$("span#checkbox_err").fadeOut("slow");
});
}
$("input:checkbox").bind("touchstart",function(){
$("span#checkbox_err").fadeIn("fast");
});
现在的问题是,当我单击/触摸复选框时,errorMsg 显示一段时间,然后它也立即隐藏它(因为目标不是 errorMsg)
如何解决这个问题?
最佳答案
据我所知,不需要实现触摸事件来实现你想要的。您可以使用常见的点击事件。它将由设备的浏览器模拟。
关于javascript - iPad Javascript/jQuery touchstart 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7010333/