For some reason, when I add a class to various inputs (after a user presses submit), this function does not record keypresses being made within those inputs. I must be doing something fundamentally wrong as I’ve tried $('incomplete_required').keyup(){} and what is below, as it seems .on() is more modern..
$(document).ready(function(){
$('.incomplete_required').on("keyup", function(){
console.log('keyed');
});
});
What have I done wrong here?
Thank you
If you are dynamically changing elements in the dom – it is best to delegate the event to an existing parent in the dom
Obviously replacing
bodywith the closest parent element that exists on dom readyBy delegating – the event will bubble up to the “parent” element – which is where the event is handled