Reputation: 1297
I've got this jQuery script which checks to see if an input field has changed, and if it has, it adds a class to an icon (which then changes colour to let the user know they have filled in the field).
$('.input-icon input').change(function() {
$(this).next(".icon").addClass('complete');
});
It works but only when the field in question is deselected after the text has been input into it. What I need is for this to run each time a key is pressed and update accordingly.
Thanks guys.
Upvotes: 0
Views: 1198
Reputation: 44740
See http://api.jquery.com/keyup/
$('.input-icon input').on('keyup',function() {
// check if input has something in it
$(this).next(".icon").addClass('complete');
});
Upvotes: 1