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

  • Home
  • SEARCH
  • 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 7530301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:52:29+00:00 2026-05-30T04:52:29+00:00

Please help a jQuery newby with the following. I have a form and I’m

  • 0

Please help a jQuery newby with the following. I have a form and I’m trying to add successive chunks of form fields when an #addMore button is clicked. With the help of this board, I have that working now. But it only works once. I’ve whittled things down to a minimal case:

<html>
<head>
<title>Reserves Form</title>
<script src="../jquery/jquery-1.7.1.min.js"></script>
<script>
$(document).ready(function() {
var chunk = $('.content').clone(true);
 $('#addMore').live('click', function() {
     alert('debug!');
     $('#container').append(chunk);
 });    
});
</script>
<body>
<div id="container">
<p class="content">lorem ipsum blah blah</p>
</div>
<button type="button" id="addMore">Add Another Paragraph</button>
</body>
</html>

When I load the page and click the button, I see the debugging alert and then a clone of the “content” paragraph appears as expected. When I click the button again, I get the alert, but not the new paragraph. Why would one response to the click work, but not the other? And how can I get them both to 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-30T04:52:31+00:00Added an answer on May 30, 2026 at 4:52 am

    You are appending the same object again and again to the same container so you won’t see any difference as if it is not doing anything.

    Try this which will clone the first .content element inside the click handler and append it.

    $(document).ready(function() {
       $('#addMore').live('click', function() {
           alert('debug!');
           $('#container').append($('.content:first').clone(true));
       });    
    });
    

    Alternatively you can try this which will append html string instead of cloned object. In this approach the clone is used only once because string appending can be done any number of times so it is better than previous approach.

    $(document).ready(function() {
       var content = $('<div />').append($('.content').clone(true)).html();
    
       $('#addMore').live('click', function() {
           alert('debug!');
           $('#container').append(content);
       });    
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem to add jQuery to some existing code, please help. We have
help please to fix my problem. i am newby in jquery ui. And have
please help with the following:(using rails 3 and jquery) In my view i have:
Please help to replace these jQuery functions with Prototype ones: $(button,input,label,select,textarea).bind('mouseover mouseout', function(){$(this).toggleClass('hover')}); $(button,input,select,textarea).bind('focus
please help me with a simple PHP doubt. I have a simple form: <
Please help I am trying to code for selectAll or clear all using Jquery.
Could someone please help with the following jQuery I need all jQuery UI buttons
Iam new to jquery. I have a rails form. where iam going to add/edit
please help with rails 3 form in jquery ui tab. This is the view(:controller
please help with this using rails 3 and jquery-ui. In my view i have:

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.