[jQuery] Binding click event handlers to dynamically added links

[jQuery] Binding click event handlers to dynamically added links


Hi, I am trying to bind Ajax click event handlers to links that I have
dynamically
appended to the DOM tree.
Basically I have:
var html = '<tr><td><a href="someurl">text</a></td></tr>'
$("#table > tbody").append(html);
If I try to add click handlers to these anchor tags, they don't work.
$("a").each(function(i, dom_element) {
$(dom_element).click(function() {
$.get('/shopping-cart/remove/'+i+'/', function(xml){
alert('test: '+i);
alert($("numbers", xml).text());
});
return false;
});
});
Anchors that were in the DOM works though.