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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:29:04+00:00 2026-06-06T01:29:04+00:00

I did some all day learning and I figured out how to add rows

  • 0

I did some all day learning and I figured out how to add rows dynamically for my form with jquery. But now I can’t for the life of me figure out how to remove that last added row.

$('#btnAdd').click(function() {
                var num     = $('.clonedInput').length;
                var newNum  = new Number(num + 1);

                var newElem = $('#input' + num).clone().attr('id', 'input' + newNum);

                newElem.children('.client').attr('id', 'client' + newNum).attr('name', 'client' + newNum);
                newElem.children('.color').attr('id', 'color' + newNum).attr('name', 'color' + newNum);

                $('#input' + num).after(newElem);
                $('#btnDel').attr('disabled','');

                if (newNum == 5)
                    $('#btnAdd').attr('disabled','disabled');

            });



<form id="myForm">
    <div id="input1" style="margin-bottom:4px;" class="clonedInput">

<select name="client" id="client" class="client">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>

<input type="text" name="color" id="color" class="color"/>

    </div>

    <div>
        <input type="button" id="btnAdd" value="Add Row" />
    </div>
</form>

And on jsFiddle for your viewing pleasure: Demo

Answer Courtesy of Blender

$('#btnRemove').on('click', function() {
    $('.clonedInput').last().remove();
});
  • 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-06T01:29:07+00:00Added an answer on June 6, 2026 at 1:29 am

    Like so?

    $('#btnRemove').on('click', function() {
        $('.clonedInput').last().remove();
    });
    ​
    

    Demo: http://jsfiddle.net/P8bTz/2/

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

Sidebar

Related Questions

I did some research but all I could find was syncing data core with
First of all, I did some searching for an answer to this question...but I
I am having problems with sets all day. Some I can solve, others not.
I'm new to ASP.NET (did some classic ASPs back in the day, but my
First of all, I did some search and no answer on stackoverflow/google provided me
all day long I am sitting and trying to find out why binding to
Good day to all... I have some little problems with ffserver and ffmpeg... What
I have been pulling my hair out on this one all day, and I'm
Did some searches here & on the 'net and haven't found a good answer
Did some googling and couldn't find a clear answer on this. My assumption is

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.