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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:48:18+00:00 2026-05-25T02:48:18+00:00

First please forgive my poor English . My Problem is that how can i

  • 0

First please forgive my poor English .
My Problem is that how can i re-declare some function for particular elements after responsing from jquery.ajax ?

Here is my code for html :

<a href="#"><img class='alrun' src="images/pic0001.png" width="97" height="97" /></a>

Here is my code for jquery to bind the click function :

$(document).ready(function() {
  $("img.alrun").bind("click", function(){
  var aaa = ($(this).attr("src") === "images/pic0001.png")? "images/pic0002.png":"images/pic0001.png";
  $(this).attr("src", aaa);
});

Everything works fine and well , the picture will swap when i click the image ,
however when i using the jquery.ajax from php script to create new DOM elements just like above code of HTML,the “new image” could not be swapped anymore ,

here is my code for more_race.php:

<?echo "<a href='#'><img class='alrun' src='images/pic0001.png' width='97' height='97' /></a>";

?>

here is my jquery code for ajax :

$("a.more_race").click(function(){
    $.ajax({
    type: "POST",
    url: "more_race.php",
    cache: false,
    success: function(html){
    $("div#new_image").html(html);
    }
    });
});

I think all my problem is that i dont know how to re-declare the function for new elements created by jquery , i hope that any one can give me some example to solve my easy problem.

Thsnk a lot!

  • 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-05-25T02:48:18+00:00Added an answer on May 25, 2026 at 2:48 am

    You need to use the jQuery .live() keyword for any control you add using jQuery or JavaScript.

    So

    $("img.alrun").live("click", function(){
      // your code here
    });
    

    and

    $("a.more_race").live....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, please forgive my bad english ;) I want to use the windows function
This is my first post, and first please forgive me for my poor english.
First, please forgive and point out if I am to use some other protocol
First, please forgive me for my approximative English. I have 2 tables, one (tb_facture)
Please see following examples first, and which one is better? Could you compare some
First of, please check this picture: As you can see, left from Today and
Can someone please explain the following How was the first JDK release unit Tested?
[please forgive formatting errors-- first post here and I tried earnestly to do it
This is my first post, so please forgive me if this question has been
I am relatively new to ggplot, so please forgive me if some of my

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.