Skip to content Skip to sidebar Skip to footer

Jquery .on() Isn't Binding Click Events To Dynamically Created Elements

I have a textbox that dynamically adds an element when I press enter, and another that deletes the element when I click the delete button. The delete method works for any existing

Solution 1:

this is wrong: $('.icon.remove').on('click'...

this is right: $(document).on('click', '.icon.remove', function)

you can use any container instead of document (which is the most highlevel container).

hope that helps

Post a Comment for "Jquery .on() Isn't Binding Click Events To Dynamically Created Elements"