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

The Archive Base Latest Questions

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

I have a hyperlink outputted by jQuery using append such as this: $(‘#content’).append(‘<div id=appenddocumentationcontent>’+documentation_contentvalue

  • 0

I have a hyperlink outputted by jQuery using append such as this:

$('#content').append('<div id="appenddocumentationcontent">'+documentation_contentvalue + " <a title='Click to Edit' id='edit_content'>[Edit]</a></div>");

The generated HTML is this:

<div id="content">
  <div id="appenddocumentationcontent">The quick brown fox jumps over the lazy dog <a id="edit_content" title="Click to Edit">[Edit]</a>
  </div>
</div>

I have a click event using jQuery that will show a text area if clicked and it works fine if the edit hyperlink is clicked for the first time (take note the selector is matched to the hyperlink):

    $('#content #edit_content').click(function() {  

          //Show textarea
    $('#textarea_documentation_content').show();    

      //Show OK button to close again this textbox

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


      //Hide edit link
    $('#documentation_edit_content').hide();

      //Hide the current content div
    $('#documentation_content').hide();     


});

Finally I have this another click event function for OK button to close the textarea, remove the original values, show the new value and show the edit link again:

    $('#OK_button').click(function() {  
            //remove original content
    $('#appenddocumentationcontent').remove();

            //hide the text area
            $('#textarea_documentation_content').hide();


            //hide the OK button
            $('#documentation_button_content').hide();

            //show again the content div
    $('#documentation_content').show();


           //Show again the edit link
    $('#documentation_edit_content').show();

            //retrieve the new text area value
    var documentation_contentvaluex= $('textarea#textareainput_documentation_content').val();

            //finally append this new value
    $('#content').append('<div id="appenddocumentationcontent">'+documentation_contentvaluex + " <a title='Click to Edit' id='edit_content'>[Edit]</a></div>");

}); 

It works near perfectly except the main problem is that the Edit link is not anymore working after pressing the OK button.

Also the generated HTML before and after pressing OK button is very similar, take a look below:

BEFORE CLICKING OK:

<div id="content">
  <div id="appenddocumentationcontent">The quick brown fox jumps over the lazy dog <a id="edit_content" title="Click to Edit">[Edit]</a>
  </div> 
</div>

AFTER CLICKING OK (with new content replaced):

<div id="content" style="display: block;">
  <div id="appenddocumentationcontent">This is the new content! <a id="edit_content" title="Click to Edit">[Edit]</a>
 </div>
</div>

As you can see, the selectors are not changed at all, it should trigger the edit link again using these selectors in the click function:

$('#content #edit_content').click(function() {  

Am I missing something? thank you so much for your tips.

  • 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-15T17:07:35+00:00Added an answer on June 15, 2026 at 5:07 pm

    If you are adding and removing elements, use .on() instead.

    $('#content').on('click', '#edit_content', function() { ... });
    

    EDIT: per comment, .live() has been deprecated in favor of .on()

    EDIT 2: proper delegation

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

Sidebar

Related Questions

I am using jquery-ui-1.8.20.min.js. I have a hyperlink on the page and am trying
I am using Powerpoint 2007 and I have set up hyperlink from slide A
I thought that this was easier… I have a asp:hyperlink control, with target=_blank ,
I have an image and a hyperlink inside a div, but for some reason,
I have this hyperlink called SEND in a ASP page called Home and here
I have this hyperlink in anchor tag <a href=/index.php?var1=rule-power > Text </a> Now i
I have a hyperlink which I am trying to reposition on the page using
I am using ASP.NET checkboxlist control. On the page I have a hyperlink. On
I have a hyperlink in my excel sheet say: http://abc.com/u?/abc,143 When i open this
I have a hyperlink that contains an image, nothing special - like this .

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.