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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:09:46+00:00 2026-05-28T11:09:46+00:00

I have the following that is created dynamically: <a class=editLink href=/location/Edit?city=05>Edit</a> This and other

  • 0

I have the following that is created dynamically:

<a class="editLink" href="/location/Edit?city=05">Edit</a>

This and other editLink rows are created dynamically.

What I would like to do is add some jQuery to these:

$(".editLink").button();
$(".editLink").click(function () {
    alert('edit link');
    return false;
});

Is there some way I can assign this BEFORE the elements appear? Also how can I deal with the following:

$(".editLink").button();

When the .editLink is not already 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-05-28T11:09:46+00:00Added an answer on May 28, 2026 at 11:09 am

    Use event delegation, by putting the handler on the document.

    $(document).on('click', '.editLink', function() {
      alert('edit link');
      return false;
    });
    

    This is called “live” or “delegated” events. The $(document) part identifies the element that will handle the event, this one must exist when this code is run. You should set this to a parent element as far down as you can. Using document is a bit overzealous, but it will work.

    The '.editLink' string identifies a selector for any child elements inside the element with the handler. When the event happens the original element is checked against this selector to see if something matching fired the event. And if so, then run the event handler.

    See working example here: http://jsfiddle.net/Squeegy/guz9A/1/

    Note how the links are not present when the handler is bound, but they still trigger the handler when they are added later on.

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

Sidebar

Related Questions

I have the following dynamically created class that is passed into the xpath function
I have an ExpenseType object that I have created with the following migration: class
I have the following dynamically created HTML block: <form class=standard settingsPage method=post enctype=multipart/form-data name=account
I have the following UL: <ul class=xbreadcrumbs style=position:absolute; bottom:0px> <li><a href=someURL>A Crumb</a></li> </ul> This
I have a modal dialog that is created with the following: procedure TFormCompose.createParams(var Params:
I have defined the following ApplicationManifest file the problem is that i have created
I have the following code that creates a serverside object of the xmlhttp class.
I have the following code that resides in my .js file //This is the
I have a list of links that are being created dynamically by another function
I have the following problem spanning dynamically added rows to a TableLayout inside a

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.