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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:26:27+00:00 2026-05-20T21:26:27+00:00

I have an unordered list of links that I am dynamically adding to on

  • 0

I have an unordered list of links that I am dynamically adding to on $(document).ready(). I am defining a handler for the live ‘click’ event on the link I am adding but it’s not triggering. I was under the impression using live() over, say click() meant the event handler is attached to elements that are dynamically added to the DOM. Here’s a code listing to help illustrate my query.

$(document).ready(function() {
    $('.activities ul').each(function() {
        appendAddTagLink($(this));
    });
});

function appendAddTagLink(ulel) {
    var thelink = $('<a>add</a>').attr('href', 'add');
    thelink.live('click', function(ev) {
        // Not getting here!
    });
    ulel.append($('<li></li>').append(thelink));
}

I’m extracting the body of the code into a function as I need to reuse it a couple of times. The strange thing is that while the live() handler does not seem to attach to the link, the last line in the function (which appends the link to an

  • element and then to the element works just fine. Also I am getting no javascript syntax errors.

    • 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-20T21:26:28+00:00Added an answer on May 20, 2026 at 9:26 pm

      No, in your code you should use bind() and not live().

      If you wanted to use live(), your code should look something like this:

      $('.activities ul').each(function() {
          $(this).append('<li><a href="add">add</a></li>');
      });
      // Some selector to grab your 'add' links
      $("a[href=add]").live("click", function(){
          // Do stuff
      });
      
      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    i have a unordered list of links, which are dynamically created by Ajax, and
    I have a page that includes an unordered list of links. I'm trying to
    I have some javascript/jquery code that dynamically populates an unordered list with a bunch
    I have an unordered list of links that I need to append the index
    I have an unordered list of links that I save off to the side,
    I have an unordered list that contains links. Some of the links are text
    I have an unordered list and the index of an li tag in that
    I have a unordered list that I want to make fill 2 columns, I
    http://clifgriffin.com/blockade2/ Ok, I have an unordered list that serves as a list of menu
    I have an unordered list of images that display inline and float next to

    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.