Here is some code:
jQuery.each(comments, function(i, comment)
{
cl.append("<div class='comment_entry' id='" + comment.id + "' style='background-color: " + colors[color] + ";'><div class='ce_time'>" + comment.time + "</div><div class='ce_poster'>" + comment.poster_name + "</div><div class='ce_comment' id='ce_comment'>" + comment.comment + "</div></div>");
color = 1 - color;
});
jQuery(".comment_entry").click(function()
{
//alert(this.ce_comment);
alert(jQuery('this').find('#ce_comment').text());
});
What I am doing here is adding DIVs on the fly. Then, I am adding a click event to the DIVs by their class. When a DIV is clicked, it should display the text in the DIV ID ‘ce_comment’. Instead, I get a blank. I know there is text in the DIV because I can see it on the page.
SO, what is the correct way to access the text in this case?
Remove the quotes around
this.