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

The Archive Base Latest Questions

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

I have some jQuery appending HTML from a PHP script. jQuery $.ajax({ type: "POST",

  • 0

I have some jQuery appending HTML from a PHP script.

jQuery

$.ajax({
    type: "POST",
    url: "newPage.php",
    data: data,
    cache: false,
    success: function(html)
    {
        $('.item1 ul').append(html);
    }
});

PHP

    echo"<li><a href=\"#\">".$pages["title"]."<img src=\"images/delete.jpeg\" class=\"delete del-page\" id=".$pages["pages_id"]." title=\"Delete Page\"/><img src=".$state." class=\"page-state\" id=".$pages["pages_id"]." title=\"Page On\"/></a></li>";

After appending, no jQuery events work on the new HTML.

  • 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-18T11:32:19+00:00Added an answer on June 18, 2026 at 11:32 am

    You need to delegate your events with .on()

    You can read specifically about this here

    But basically you need to attach the listener higher up in the DOM heirarchy.

    so instead of this…

    $('.selector').on('event', function(e) {...});
    

    do this

    $('.item1 ul').on('event', '.selector', function(e) {...});
    

    Why?

    This works because the dynamic elements that are not yet on the page when you bind the events, still fire the events, they just don’t have the handlers.

    Thanks to event bubbling all DOM elements up the tree will hear their descendant’s events (unless propagation has been stopped), and can act on them accordingly.

    In this example, when '.item1 ul' hears that an 'event' has been triggered from one of it’s child elements, if it was '.selector' that triggered it, the handler will fire.

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

Sidebar

Related Questions

I have some jquery/php interaction set up on a page. It submits some data
I have some jquery code that is doing an ajax lookup and returning comma
I'm doing some work in HTML and JQuery. I have a problem of my
I have some strange behaviour going on with the jQuery ajax functionality in my
Hello I have a jQuery function that will send to a php file some
Ajax-returned HTML includes a table and a submit button (type=button) The table includes jQuery
I have an html form and some jQuery that validates the form. If all
I have some jQuery code like this : $(function($) { $('input.autonumeric').autoNumeric({aSep: ',', aDec: '.',vMax:'1000000000000'});
I have some jQuery tabs on a website and I am trying to make
I have some jquery which will calculate the items in my menu and assign

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.