jquery点击不工作触摸

时间:2015-03-31 17:16:20

标签: jquery touch

当我在图像上单击鼠标时,它将执行//某些操作

当我触摸笔记本电脑触摸屏上的图像时,它什么也没做。

是否需要使用其他事件?

这是我的代码?

$("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");
});

1 个答案:

答案 0 :(得分:1)

$("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");
});