Is it possible that the code you pasted here is being executed before the new DOM node is actually available? If so, you can try using the .ready() method and attach your click after the fact.
$("#id").ready(function() {
$("#id").click(function() { alert("test"); }
});
EDIT: I am somewhat new to jQuery myself, and I thought that the .ready() method was usable by more than just the document object. If this turns out to not be true, it looks like there is a jQuery plugin, jQuery.Listen, that does something similar:
// Listen to clicks, even for newly added instances of #id.
jQuery.listen( 'click', '#id', function(){ alert("test"); });
Something like this would be nice if you can use classes for your dynamically added anchors.
// Listen to clicks for anything with the class "dynamicAnchors", even newly
// added anchors.
jQuery.listen( 'click', '.dynamicAnchors', function(){ alert("test"); });