Monday, April 16, 2012

jQuery bind to keyup only, not focus

This seems like a simple thing but google hasn't turned up anything for me:



How can I bind to a text / value change event only, excluding an input gaining focus? Ie, given the following:



$(function(){
$('input#target').on('keyup', function(){
alert('Typed something in the input.');
});
});


...the alert would be triggered when the user tabs in and out of an element, whether they actually input text or not. How can you allow a user to keyboard navigate through the form without triggering the event unless they input/change the text in the text field?





No comments:

Post a Comment