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 7981747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:28:14+00:00 2026-06-04T10:28:14+00:00

I wrote the code to update the posts by using the ajax: $(function(){ $(‘#loadFeed’).bind(‘click’,function(){

  • 0

I wrote the code to update the posts by using the ajax:

 $(function(){
   $('#loadFeed').bind('click',function(){ 
        $.getJSON('getData.php', function(json) {
            var output="<ul id='feedsList'>";

            for(var i=json.posts.length-1;i>=json.posts.length-31;i--){
                output+="<li class='post'>";
                output+="<div class='text'>"+json.posts[i].shortmsg+"</div>";         
                output+="</li>";
            }
            output+="</ul>"
            $(output).appendTo('.posts');
    });
  });
});

My html code:

<div data-role="content" class="ui-content" role="main">
        <div class="posts"></div>
 </div>

Then I wanted to click each post, the post will expand to show more detailed content.How can I do that? The code I wrote was:

$(function(){
     $('.text').bind('click',function(){
         $.getJSON('getData.php', function(json){   
         var thisID = this.id;      
         $(this).replaceWith("<div class='long_text'>"+json.posts[thisID].msg+"<div>"); 
         });
     });
});

But it didn’t do anything.I was not sure if

var thisID = this.id;

worked or not. I changed my code a little bit:
$(function(){
$('.text').bind('click',function(){
alert("Hello!")
});
});

Still nothing happened!!I doubted if the .text was selected in the function.Anyone can help?Thanks!

  • 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-04T10:28:15+00:00Added an answer on June 4, 2026 at 10:28 am

    You should read about jQuery’s .on()

    Let’s say you have a container that exists before the dynamic content,

    <div class="posts">
        <!--dynamic content here-->
    </div>
    

    then you attach a handler once to the existing container, and it will listen to the dynamic content’s events 

    //"add listener for .text, attached on .post"
    $('.posts').on('click','.text', function(){
        //do stuff when text is clicked    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an Ajax update panel and have recently added ASP.NET tracing code to
I wrote my code using this article at msdn as a primary helper My
I have this code to update users data, but I can't write the for
I updated my code like Andro wrote about to me: public class ZiiziiActivity extends
I want to write a simple task which will update and commit source code
i added sharekitkit my project. And wrote code like here : SHKItem *item =
I wrote some code to read a file in my Java Servlet class. (I'm
I wrote a code to show a div element(shareform) when a link is clicked
I wrote a code sometime ago in which the object of ResultSet class res
i wrote following code to create a linkbutton programmatically, but its showing like lable

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.