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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:22:20+00:00 2026-06-14T22:22:20+00:00

I have a click function… $(‘.rx’).children().on(‘click’,function(){alert(‘got here’);}); My divs (50 of these div sets

  • 0

I have a click function…

$('.rx').children().on('click',function(){alert('got here');});

My divs (50 of these div sets on the page)…

<div class="rx"><div id="'.$data_string.'" class="'.$button_image_class.'"><a  href="#" ></a></div></div>

(each is a css sprite image button, which sends the $data_string in the id to a function “process_me”. I’ve replaced the call to process_me with an alert(‘got here’); for this question. FYI the $button_image_class is variable, as a particular image is loaded depending on the member’s account)

It all works beautifully, until I use pagination to load in more of the above divs (another 50, exactly the same bar $data_string, which is different in all the divs anyway).

The sprite image button links in the first 50 divs work how they should – clicking them prompts ‘got here’. However, the links in the newly loaded div sets don’t work.

I first guessed it’s because the DOM isn’t picking up the new elements, but .on(‘click’,function()… is supposed to pick up future elements. So now I’m thinking it’s something in

$('.rx').children().on('click',function(){alert('got here');});

that I’ve done wrong.

Anything sticking out there?

  • 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-14T22:22:21+00:00Added an answer on June 14, 2026 at 10:22 pm

    No, .on will only bind to existing elements unless you use a delegated event.

    Option #1

    Bind to the click event for the newly added elements in a callback (after the elements have been added to the DOM):

    $.ajax({
        ...
    }).done(function(){
        $('.rx').children().on('click', function() { 
            alert('got here');
        });
    });
    

    Option #2

    Use a delegated event that you bind to the container:

    $(document).on('click', '.rx > *', function() { 
        alert('got here');
    });
    

    Note: You probably want to replace the asterisk in the selector with an actual element type or class that matches the children. Using asterisk in selectors should be avoided when possible. Another improvement of the above is to use a parent that is closer to .rx instead of binding directly to document

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

Sidebar

Related Questions

I have this code here that should send off an alert... jQuery(.wpcart_gallery .thickbox).click(function($){ alert('hi');
I have this: $(document).ready(function() { $(input[type=button]).click(function () { $(#test).html(W3Schools); alert(Would submit: + $(this).siblings(input[type=text]).val()); $.ajax({
I have a click function that grabs the #id of a DIV all the
I have a click function setup to make a div resizable. When I click
I have this jquery code : $(document).ready(function() { $('div.badge_button > .more').click(function() { var id
I have a page with multiples divs like this <div class=bigbox> <a href=http://www.somestuff.com>some stuff</a>
I have a click function which grabs the contents of one div and loads
I have a click event function like so: $('.expand2').click(function(e) { alert('in'); e.preventDefault(); var obj
I have click events set up like this: $('.dialogLink') .click(function () { dialog(this); return
I have an click function that I want to trigger outside of the function

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.