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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:15:34+00:00 2026-06-15T08:15:34+00:00

I have the following code: var $reviewButton = $(‘span.review_button’); $reviewButton .live(‘click’, function(){ $(‘#add_reviews’).show(); }

  • 0

I have the following code:

var $reviewButton = $('span.review_button');

$reviewButton
    .live('click',
        function(){

            $('#add_reviews').show(); 

        }
    )

Later in the script, I use an AJAX call to load some content and another instance of $(‘span.review_button’) enters the picture. I updated my code above to use ‘.live’ because the click event was not working with the AJAX generated review button.

This code works, as the .live(click //) event works on both the static ‘span.review_button’ and the AJAX generated ‘span.review_button’

I see however that .live is depracated so I have tried to follow the jquery documentations instructions by switching to ‘.on’ but when I switch to the code below, I have the same problem I had before switching to ‘.live’ in which the click function works with the original instance of ‘span.review_button’ but not on the AJAX generated instance:

var $reviewButton = $('span.review_button');

$reviewButton
    .on('click',
        function(){

            $('#add_reviews').show(); 

        }
    )

Suggestions?

  • 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-15T08:15:36+00:00Added an answer on June 15, 2026 at 8:15 am

    The correct syntax for event delegation is:

    $("body").on("click", "span.review_button", function() {
        $("#add_reviews").show(); 
    });
    

    Here instead of body you may use any static parent element of "span.review_button".

    Attention! As discussed in the comments, you should use string value as a second argument of on() method in delegated events approach, but not a jQuery object.

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

Sidebar

Related Questions

I have the following code: var numberOfSelectedOptions = new Array(); numberOfSelectedOptions[0]=0; numberOfSelectedOptions[1]=0; numberOfSelectedOptions[2]=0; $(a.tagvariantoption).live(click,
I have the following code: var clickCount = 1; var slideCount = $('div.slide').length; $('a#next-button').click(function()
I have the following code: var submitHandler = function ($link, $form, close) { var
I have the following code: var refreshId = setInterval(function() { $(#footad).html('myjshere'); }, 15500); Where
I have the following code: var from = 0, step = 5; function showNext(list)
I have the following code: var string = word1;word2;word3,word4,word5,word6.word7; function ends_with(string, character) { var
I have the following code: var words = new Object(); $(li.words).each(function(){ var thisId =
I have the following code: var formSubmitHandler = function (link, form) { //e.preventDefault(); var
I have the following code: var parentEls = $(root) .find(credit standard) .parents() .map(function ()
I have the following code: var A = function() {}; var a = new

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.