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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:04:32+00:00 2026-05-31T03:04:32+00:00

Here is my AJAX call: $.ajax({ type: ‘POST’, url: ‘<?php echo site_url(‘channel_partners/cms/get_news’); ?>’, data:

  • 0

Here is my AJAX call:

    $.ajax({
        type: 'POST',
        url: '<?php echo site_url('channel_partners/cms/get_news'); ?>',
        data: data,
        dataType: 'json',
        success: function(data, status, xhr) {
            var json = JSON.parse(data);
            for (var i=0; i<json.length; i++) {
                $('ul#news').append(
                '<li id="' + json[i].article_id + '"><a class="deleteItem" title="Delete Item" href="#">Delete</a> 
<a id="editItem" title="Edit Item" href="#" target="_blank">Edit</a>
 <a href="#" target="_blank">' + json[i].title + '</a></li>'
               );               
                 }
         },
        error: function(xhr, status, error) {
            //alert('Error: ' + status + ' ' + error);
            console.log(xhr)
        }
    });

My question is this: When I have just a regular link with a class of “deleteItem”, it fires a deleteItem click event. The event works fine. But when the HTML is added programatically through jQuery, the link is not clickable any more. Why is it not clickable. It’s like jQuery isn’t recognizing it. What do I need to do to make the event fire? I tried adding the class programatically but that didn’t work.

  • 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-31T03:04:33+00:00Added an answer on May 31, 2026 at 3:04 am

    Elements added dynamically to the dom should use .on for jQuery v1.7 and .live/.delegate for older versions.

    Please note that for older versions, using .delegate is preferred over using .live

    In your case it should be,

    Using .on (jQuery v1.7)

    $('#news').on ('click', '.deleteItem', function () {
     //delete code
    });
    

    For older versions using .delegate, [preferred method]

    $('#news').delegate('.deleteItem', 'click', function () {
     //delete code
    });
    

    or using .live,

    $('.deleteItem').live ('click', function () {
     //delete code
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my ajax call $.ajax({ type: POST, url: MyMethod, contentType: 'application/json; charset=utf-8', data:
I have this ajax call at the moment: $.ajax({ url: misc/sendPM.php, type: POST, data:
I have a jQuery .ajax call: $j.ajax({ type: POST, url: /Services/Cart.asmx/UpdateQuantity, data: data, contentType:
I have following ajax call: $(#container).html(loading...); $.ajax({ url: somedoc.php, type: POST, dataType: html, success:
Going slightly crazy here. I'm making an Ajax call using jQuery.post as follows: $.post('php/print.php',{data:dS},function(res){...
Here is my AJAX call: $(document).ready(function () { $(#btnSignup).click(function () { $.ajax({ type: POST,
Hi. I was trying to access backend URL from an AJAX call and here's
i've got a simple ajax call: function message(){ $.ajax({ type: GET, url: /file/timestamp=+ timestamp,
I'm doing the following ajax call: //exif loader function LoadExif(cImage) { $.ajax({ type: POST,
I have the following ajax call: $(#welcome a.close).click(function(e) { $.ajax({ type: GET, url: /visitors/hide_welcome,

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.