2015-03-31 6 views
2

Когда я нажимаю вниз на моей мыши на изображение, он будет делать что-то //JQuery по щелчку не работает для сенсорного

Когда я касаюсь изображение на моем ноутбуке сенсорный экран он ничего не делает.

Возможно, мне нужно использовать другое мероприятие?

Это мой код?

$("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

Может быть, этот вопрос может помочь вам - http://stackoverflow.com/questions/4755505/how-to-recognize-touch-events-using-jquery-in-safari-for-ipad- возможно-то – abaracedo

+1

Человек ваш удивительный thx. (Я пытался найти, но не нашел ничего, очень изнашивался) –

ответ

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"); 
}); 
Смежные вопросы