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

  • Home
  • SEARCH
  • 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 8961407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:53:07+00:00 2026-06-15T15:53:07+00:00

I have a script doing a mysql query and populate a table using $(‘#results’).html(returnData);

  • 0

I have a script doing a mysql query and populate a table using

  $('#results').html(returnData);

The mysql results contains data that should be clickable and reloaded into the same table (replacing the previous query).

Simplifying and boiling it down, the following code does not work:

   <head>
    <script>
    $(document).ready(function() {
        $('.a').click(function() {
            $('#results').html('THIS IS VALUE FROM LINK A <a href="#" class="b">B</a>');
        });

        $('.b').click(function() {
            $('#results').html('THIS IS VALUE FROM LINK B');
        });
    });​
    </script>
    </head>
    <body>
    <div id="results">THIS WILL BE REPLACED WITH VALUE FROM LINK A OR B</div><BR>
    <a href="#" class="a">LINK A</a><BR>
    <a href="#" class="b">LINK B</a>

If I click LINK A OR B the div id="results" is populated OK, but when I place the same link inside one of the .html results returned from click functions the link is not working and the div id”results” is not reloading itself.

So my questions are; why would that not work? and what would be the best way to reload the same table based on what you click inside the table that is already passed from .html()? I do not want to pass the clicked value on to a new page.

UPDATE:
This will work using .on()

<script>
$(document).ready(function(){

$('body').on('click', '.a', function() { 
    $('#results').html('THIS IS VALUE FROM LINK A <a href="#" class="b">B</a>');
});

$('body').on('click', '.b', function() { 
    $('#results').html('THIS IS VALUE FROM LINK B');
});

});
</script>

</head>

<body>
<div id="results">THIS WILL BE REPLACED WITH VALUE FROM LINK A OR B</div><BR>
<a href="#" class="a">LINK A</a><BR>
<a href="#" class="b">LINK B</a>
  • 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-15T15:53:08+00:00Added an answer on June 15, 2026 at 3:53 pm

    To elaborate on Abhilash’s comment, the reason your click event isn’t firing is due to the event listener only being attached to elements which currently exist in the DOM at the time onReady is executed.

    .live() was introduced in older versions of jQuery – now deprecated in favor of .on() – to combat this problem. It allows you to attach events to a static element like body, and when the click event propagates up to the body it checks the original target element which triggered the event against your .on() selector, if they match it executes the handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a server-side php-script that fetches results from a MySQL table. I am
I'm using a jQuery script for a table which paginates and searches through data.
I have a PHP script which runs a MySQL query. $query = INSERT INTO
I have a sed(1) script doing many step-by-step transformations (substitutions) of a given input
Suppose I have a script: my_script.sh Instead of doing ./my_script.sh I want to do
I have a Python 3 script that is going to be doing some regex
I am doing a batch scripting assignment where I have to call one script
In my main script, I am doing some archive manipulation. Once I have completed
I have script which allows to display Bing search results. I can call for
I have to store hindi text in a MySQL database, fetch it using a

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.