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