In JQuery, how to make an action when choosing an input with a mouse click? -


as can see below, there history addresses chan choose in formular, when choose 1 , press "enter" color adapt (become green if it's mail address, or stay red if not). did using piece of code (jquery):

  $( "#mail" ).keyup(function() {      if(!validateemail($("#mail").val())) {         $("div.mail").removeclass("has-success");         $("div.mail").addclass("has-error");     }     else{       $("div.mail").removeclass("has-error");       $("div.mail").addclass("has-success");       }      }); 

enter image description here

but problem if click "history" email address mouse instead of pressing "enter", nothing happens (even if choose mail address). tried other jquery functions .mouseup() or .click() still not work.

do have idea ?

try this:

$('#selector').focus(function(){     // code here }); 

focus event fires when element focus either mouse selection or tab.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

python - Error: Unresolved reference 'selenium' What is the reason? -

php - Need to store a large amount of data in session with CI 3 but on storing large data in session it is itself destorying automatically -