当我在图像上单击鼠标时,它会执行//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/