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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:03:06+00:00 2026-06-17T11:03:06+00:00

I created elements with classes from an AJAX call. I’m trying to bind a

  • 0

I created elements with classes from an AJAX call. I’m trying to bind a click event to these created object.

When I create an element with the same handler class as the AJAX create elements, it binds just fine. But when the handler elements are created from the AJAX call, they don’t bind to the .click function.

I suppose it has something to do with when the elements are loaded. Will I need something like a promise statement for the .click() function?

If needed, you here’s my code.

Create the elements

function runQuery(){

var url = 'http://www.nexthometown.com/index.php?option=com_singleprop&view=raw&format=raw';

$.ajax({
    url: url,
    dataType: 'json',
    success: function(data){ 
        $.each(data, function (key, value){
            var agentuid = value[0];
            var mlsnum = value[1];
            var address = value[5] + ' ' + value[6] + ' ' + value[7];
            var city = value[9];
            var state = value[10];
            var zip = value[11];
            $('#ohs_table').append('<tr><td>' + mlsnum + '</td><td>' + address + ' ' + city + ' ' + zip + '</td><td><div class="media_button">QRCode</div><div class="f_button media_button" value="' + mlsnum + '">Flyer</div></td></tr>');
        });
    },
    error: function(jqXHR, error, errorThrown) {  
        alert(jqXHR.responseText); 
    }
});


};

The .click Function

$('.f_button').click(function(){
    $('#test').html('<h1>Hello!</h1>');
});
  • 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-17T11:03:07+00:00Added an answer on June 17, 2026 at 11:03 am

    $('.f_button') returns a collection of elements that exist when you call the selector. It won’t take new elements into account.

    Use the event delegation syntax of .on() and attach the click event to an already existing parent element:

    $('#ohs_table').on('click', '.f_button', function(){
        $('#test').html('<h1>Hello!</h1>');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add results from an object to newly created HTML elements: *long
I'm trying to replace a div with created elements, going from: <div id='links'></div> to
I'm trying to remove an event listener for created span elements where the function
I am trying to lookup elements within a dynamically created element. For some reason
I want to create a java classes from the xsd using xjc ant task.
I'm trying to create a XML structure (not read/write from/to a file, only the
I'm trying to create a form by inheriting from another form I have already
I'm trying to generate Java service classes from a WSDL definition I have already
When I am trying to generate Apex classes from the below WSDL file I
Here is my attempt, xsd and classes created from xsd.exe Running my code I

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.