2

When I click down on my mouse on the image it will do //something

When I touch the image on my laptop touchscreen it does nothing.

Is it that I need to use a different event?

This is my code?

$("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
    Maybe this question can help you - http://stackoverflow.com/questions/4755505/how-to-recognize-touch-events-using-jquery-in-safari-for-ipad-is-it-possible – abaracedo Mar 31 '15 at 17:19
  • 1
    Man your amazing thx.(I tried to find but coulnd't find anything, very weard) –  Mar 31 '15 at 17:22

1 Answers1

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