I believe I could do this with .live but that method is deprecated. Here's the issue:
I have a click handler function that should fire on any element with the class "myClickEl" for example. This works fine on "myClickEl" elements that are present in the document at the time its loaded. However, if I add a myClickEl element after the DOM has loaded, the click handler does not fire.
Here's the code. I've tried both methods below:
Option 1:
jQuery('.myClickEl').on('click', function(){
var formText='This is some text to paste';
jQuery(this).parent().next('textarea').val('');
jQuery(this).parent().next('textarea').val(formText);
});
Option 2:
jQuery('.myClickEl').click(function(){
var formText='This is some text to paste';
jQuery(this).parent().next('textarea').val('');
jQuery(this).parent().next('textarea').val(formText);
});