attaching events to dynamically added elements
I have a form where the user can add new fields by clicking 'add another item' button. Each new field has a 'remove' button attached to they can remove that field if they don't need it. the remove buttons all have the same class: 'removeItem'. Then, in my jQuery I have the following:
$(".removeItem".click(function(event){
$(this).parent().remove();
});
The only element that this woks on is the original element in the source, but not any of the dynamically created elements which basically look like this:
<li>
<a href="#" class="removeItem">remove</a>
<input />
</li>