Reputation: 509
I'm trying to act on fields which have the parsley-error class, unfortunately the following code isn't working.
$('.parsley-error').on('focusin', function() {
console.log('yep');
});
if I change it to this:
$('input').on('focusin', function() {
console.log('yep');
});
then that works, so I know the code is being run ... just that the selector isn't working. Any help is, of course, much appreciated.
Upvotes: 0
Views: 167
Reputation: 79562
When you are calling $('.parsley-error').on...
, your jQuery set is probably empty, as there aren't any errors yet. So your code does nothing.
You probably want to use delegated events $(document).on('focusin', '.parsley-error', ...)
instead. Or use the parsley events to do stuff when there's an error.
Upvotes: 2