Getting event handler to handle newly added elements
I'm new at jQuery and probably misunderstanding something fairly fundamental. I have a table that looks like this:
<table border="1" id="classMembers">
<tr><td><a href="#">something</td></td>
</table>
When something somewhere else is clicked, the following gets executed, and the new rows appear in that table on the web page just fine:
$('#classMembers')
.append('<tr><td><a href="#">dummy</a></td></tr>');
The following event handler works when I click the "something" row, but not when I click one of the rows that got added to the table after loading the page:
$(function()
$("#classMembers tr > td > a").click(function() {
alert("test");
});
});
How do I get an event handler to handle clicks of elements that were added by jQuery code after the page was loaded?
thanks,
Bob