Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9136719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:59:24+00:00 2026-06-17T08:59:24+00:00

Here is some code: jQuery.each(comments, function(i, comment) { cl.append(<div class=’comment_entry’ id=’ + comment.id +

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:59:25+00:00Added an answer on June 17, 2026 at 8:59 am

    Remove the quotes around this.

    jQuery(this).find('#ce_comment').text()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is some code: var class = function(elem,div){ this.elem= elem; this.div = div; this.init
I'm refactoring some code at the moment and have come across a selector: jQuery(tr,#ctl00_MainContent_MyUserControl).each(function(i,row)
I'm using the JQuery DropdownChecklist as available from here: http://code.google.com/p/dropdown-check-list/ Basically I'm using some
I'm having some trouble with the jQuery hover method. Here's the relevant JavaScript code:
Here is some code: class Person def initialize(age) @age = age end def age
I wrote some code in jquery to loop through some images inside a div,
I'm having issues with some jQuery code I have. Using $.each I am looping
I'm trying to incorporate some code from Stack user DannYo's comment here , however
I have some code here: $(document).ready(function() { $(#querybox).live(keyup, function(e) { var code = (e.keyCode
I have some JQuery code that converts all HTML elements of a specific class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.