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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:46:06+00:00 2026-06-09T21:46:06+00:00

This almost works http://jsfiddle.net/RfWsy/4/ $(document).ready(function() { function addRows(label, maxRows, minRows) { $(‘.add-‘ + label).live(‘click’,

  • 0

This “almost” works http://jsfiddle.net/RfWsy/4/

$(document).ready(function() {

  function addRows(label, maxRows, minRows) {
  $('.add-' + label).live('click', function() {
    if ($("." + label + "-group").length < maxRows) {

      var newrow = $('#' + label + '-template')
        .clone().removeAttr('id');

      newrow.insertAfter($(this)
        .closest('.' + label + '-group'))
        .find('.minus').show();

      newrow.find('input').val('');
      newrow.find('select').val('');

    }
  });

  $('.remove-' + label).live('click', function() {
    if ($("." + label + "-group").length > minRows) {
      $(this).closest('.' + label + '-group').remove();
    }
  });
}
  addRows('hs-community-service', 3, 1);
});​

The user can add up to three sets of fields, then remove all but one. That works, but after removing all but one set (by clicking the first minus link at very top), try clicking the add button, you’ll notice it does not add a new set of fields.

Any help is appreciated.

  • 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-09T21:46:07+00:00Added an answer on June 9, 2026 at 9:46 pm

    How about changing the line:

    $(this).closest('.' + label + '-group').remove();
    

    to:

    $("." + label + "-group").last().remove();
    

    jsFiddle example

    BTW, .live() has been deprecated in favor of .on() in the latest versions of jQuery (which is what the example uses).

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

Sidebar

Related Questions

I have the following jsfiddle setup: http://jsfiddle.net/eyTBZ/2/ Basically almost everything works, apart from when
I got a CSS question related to this fiddle: http://jsfiddle.net/r584e/ Here the relevant screenshot
I've got this site: http://p33.yamandi.com/ Almost everything works fine, except one little annoying thing
Could you try this simple example and tell me what's going wrong: http://jsfiddle.net/ca11111/unQWP/1/ .
This answer works almost perfectly for my needs. The problem is that it will
First, a jsfiddle... http://jsfiddle.net/therocketforever/jYba3/11/ // Highlight selected linker link & set all others to
This happens almost every time I init a new repo. Start a new project.
This is almost certainly a very silly question, but for some reason I'm having
I'm trying this for almost two hours now, without any luck. I have a
I've been wrestling with this for almost 2 hours now and no luck. I

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.