I am writing a Google Chrome Extension that needs to capture addresses in the "To" field of a new GMail e-mail. This is what I currently am working with (jQuery 2.0.2 is being used):
$('textarea[name="to"]').bind("enterKey",function(e){
alert($('textarea[name="to"]').val()); // this is definitely the "To" field
});
$('textarea').keyup(function(e){
if(e.keyCode == 13) {
$(this).trigger("enterKey");
}
});
Each time I press Enter
in the To field with the code above, an empty alert()
box fires. However, if I change the alert()
to display an arbitrary value, like alert('david');
the message david
is inside the alert box.
My question is, why is there an empty string coming off of the "To" field's .val()
when I press Enter
?
Thanks!