I am new to jQuery and JavaScript in general. I noticed that if you insert an element through jQuery in the DOM and try to perform an action on this element later, it fails. For instance:
I add the "listenToField" class to all the input elements on the page:
$(function() { $('input').addClass('listenToField'); });
Then when I add the second function:
$(function() { $('input').addClass('listenToField');
He does not warn "Hello there."
However, if I rigidly set the listenToField class to HTML inputs, a warning is generated. How can I still work when jQuery dynamically inserts a class without resorting to hard coding?
source share