This is what happens on event:
$(\'div#pages\').append($(\'...\'));
And then, on another eve
You just need to use live method:
$('.element').live('click', function(){ alert($(this).html()); });