Hello,

I'm working on a form that allows the user to click an "Add an Item" button
in order to add another item to their order.  When this button is clicked, I
have jQuery add another couple of fields to the form, so the user can input
the data.  Along with the added form fields, a "Remove This Item" button is
also added to the DOM.  All of this portion works nicely.  It's the reverse
that I'm having trouble with.

What I'm trying to do is to call empty() on the container of the clicked
"Remove This Item" button (actually, an anchor).  I am getting no errors at
all in FireBug, but when the anchor is clicked, the jQuery script is
completely ignored and the browser follows the link.

So, my question is: does jQuery support manipulation of an element that has
been added to the DOM via Javascript?  I would assume that it does, but I'm
not understanding why my "remove" function (code below) is being ignored.

$("a.remove-item").click(function() {
    var splt = $(this).attr("id").split("-");
    var n = splt[1];
    $("#container-" + n).empty();
    return false;
});


Thanks in advance,

Matt

Reply via email to