jquery on click 不适用于触摸

标签 jquery touch

当我在图像上单击鼠标时,它会执行//something

当我触摸笔记本电脑触摸屏上的图像时,它没有任何反应。

我需要使用不同的事件吗?

这是我的代码?

$("img.showPassword").on("mousedown", function(){
    $(this).next().attr("type", "text");
    $(this).attr("src", "icons/eye.png");
});
$("img.showPassword").on("mouseup", function(){
    $(this).next().attr("type", "password");
    $(this).attr("src", "icons/eye_close.png");
});

最佳答案

$("img.showPassword").on("touchstart", function(){
    $(this).next().attr("type", "text");
    $(this).attr("src", "icons/eye.png");
});
$("img.showPassword").on("touchend", function(){
    $(this).next().attr("type", "password");
    $(this).attr("src", "icons/eye_close.png");
});

关于jquery on click 不适用于触摸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29374563/

相关文章:

jquery - Spring Security 3.1 - 发生 session 超时时自动重定向到登录页面

iphone - 仅在 Superview 上禁用触摸事件?

android - 使用 iScroll.js 插件后,在 Android 中单击文本字段时不会出现虚拟键盘

javascript - 以编程方式设置选择的文本 - jquery

Android getX/getY 交错相对/绝对坐标

Android 在图像的可见部分注册触摸事件?

Android 在触摸事件上移动 View

javascript - c# - 使用 Jquery 进行 AJAX 调用时出现问题

javascript - 使 Twitter 小部件与 DIV 高度相同

javascript - 如何将视差对齐到 div 的中间?