I am creating a series of div blocks that allow users to add / remove elements from each window using jQuery. I found that after adding a new element to the field, the click function associated with this element will not respond. Here's what my code looks like:
$(".add").click(function() { $("#targetbox").append("<span class='remove'>This element was added</span>"); }); $(".remove").click(function() { alert("removing"); $(this).remove(); });
If I pre-populate #targetbox with elements, they respond to the click function. These are only elements that are dynamically added that do not respond to the function.
javascript jquery append click
Jarred
source share