Selectors on new added classes

Selectors on new added classes

Dear gurus,

I dynamically create several divs objects, then I try to add the "click" functions with the selectors but it seems that it adds only to static objects that declared in html.

for example:
$(function(){
$("<div>").addClass("message-date").text(strCurrDate).appendTo(div_head_date);

$('.message-date').click(function(){alert("DDD");});
}



the "message-date" class that I added as a new div will not get the click event.

is there a way to select new added objects with the selectors somehow ?

Please advice,
Sallaboy