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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:10:31+00:00 2026-06-10T03:10:31+00:00

I am trying to clone a row into content by creating unique ID yet

  • 0

I am trying to clone a row into content by creating unique ID yet I am facing some issues.

HTML:

<div class="content">
    <div id="email-container" class="email-container">
            <input type="text" value="" placeholder="Email">
            <input type="text" value="" placeholder="Email">
            <input type="text" value="" placeholder="Email">
            <span class="plus-button">+</span>
        </div>
</div>

JavaScript:

$('.plus-button').click(function(){
    $('.email-container').clone().insertAfter(".email-container").end();
    $('.email-container').find('.plus-button').text('-').not(':last-child');
});

​
Please find my fiddle below:

http://jsfiddle.net/meetravi/GCRVS/3/

I am trying to clone #email-container and add it inside .content with clearing the textbox values and also need to change the .plus-button value to “-” except the last row.

  • 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-10T03:10:32+00:00Added an answer on June 10, 2026 at 3:10 am
    <div class="content">
        <div id="email-container" class="email-container">
            <input class="1" type="text" value="" placeholder="Email">
            <input class="1" type="text" value="" placeholder="Email">
            <input class="1" type="text" value="" placeholder="Email">
            <span class="plus-button">+</span>
        </div> 
    </div>
    
    $(document).ready(function()
    {
        $('.plus-button').click(AddNewRow);
    });
    
    function AddNewRow(event)
    {
       var clone = $('.email-container').last().clone().appendTo('.content');
       clone.children('.1').val(''); //delete all values of your clone
       clone.children('.plus-button').bind('click', AddNewRow);
    
       var btn = $(this).parent().find('.plus-button');  //The cloned button
       btn.text('-');
       btn.removeClass('plus-button');
       btn.addClass('minus-button');
       btn.unbind('click');  //unbind the "old" click event
       btn.click(RemoveRow);
    }
    
    
    function RemoveRow(event)
    {
        $(this).parent().remove();
    }
    

    This should do the trick.
    TIPP: When you are creating new elements in your DOM you should bind the item manually or use “on”

    EDIT: Removed .live() because of its deprecation

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

Sidebar

Related Questions

I am trying to format some bad html to output into a pop window.
I'm getting an error when trying to deserialize some data into a class. The
I am trying to clone my project on google code svn into a local
I am trying to bulk insert some data into an oracle db. I followed
I'm trying to add a row into a mysql database table using visual studio
I am currently trying to simply insert a new row into my SQLite3 database
I'm trying to load a SQL row of numbers into multiple text boxes. Basically
I'm trying to clone my personal fork on github using the git+ssh protocol with
In the code below I am trying to clone a git repository to another
I'm getting this strange error message when trying to clone or pull from git.

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.