jQuery live keydown doesn't register until second keydown
- by Simon
Hi there,
I'm trying to add a class (.active) to a text field once the user starts typing. I got it to work somewhat with the following code, but for some reason the .active class is not applied immediately when the user starts typing, it's only applied after a second letter has been typed. Any ideas?
$(document).ready(function() {
loginField = $('.field');
loginField.live('keydown', function(){
if ($(this).val()){
$(this).addClass('active');
}
});
});