jquery 点击对触摸不起作用
jquery on click not working for 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");
});
当我在图像上单击鼠标时,它会执行 //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");
});