Consider the following code, in theory the click event should bind to each element but for some reason (unbeknown to me) it will only bind to the last link. does anyone have any ideas?
$.each(data, function(i,aitem){
linkid = 'address'+i;
$("#SearchResults").html($("#SearchResults").html()+'<p><a id="'+linkid+'" href="#">'+ aitem.Address +'</a></p>');
$('#'+linkid).bind("click", function(){
otherfunction(i);
return false;
});
});