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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:09:47+00:00 2026-05-23T22:09:47+00:00

why after two click this code adding several input together? $(‘.add_input’).live(‘click’, function () {

  • 0

why after two click this code adding several input together?

$('.add_input').live('click', function () {
            var scntDiv = '.'+$(this).closest('div.find_input').find('div').attr('class');
            var i = $('.adding').size();
            var input = $(scntDiv).clone().wrap("<div>").parent().html();
            alert(scntDiv)
            $(scntDiv + ' .add_input').remove();            
            $(input).appendTo(scntDiv);
            $('<div><a href="" class="remove_input"></a></div>').appendTo('.add_in');
            $(scntDiv + ' .add_in div a:first').remove('')
            i++;
            return false;
        });

html: (i use of this html twice)

<div class="column find_input">
    <div class="ai_service">
            <div class="column">
                <div class="mediumCell">
                    <input type="text" name="name" style="width: 160px;" placeholder="خدمات دیگر" title="نام پکیج تور خارجی">
                </div>
            </div>
            <div class="column" style="margin: 5px 3px;">
                <div class="mediumCell add_in">
                    <a href="" class="add_input"></a>
                </div>
            </div>
    </div>
</div>
  • 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-23T22:09:47+00:00Added an answer on May 23, 2026 at 10:09 pm

    Hmm if you’re just trying to add an extra input field, your code seems a little overcomplicated for that… Try this?

    $('a.add_input').live('click', function(e) {
        e.preventDefault();
        var $this = $(this);
        var $wrapper = $this.closest('div.find_input');
        var $input = $wrapper.find('input[name=name]').eq(0).clone();
        $wrapper.children('div').eq(0).append($input);
    };
    

    I didn’t replicate everything from your code, just the cloning/adding new input. If you posted simplified code and my example doesn’t apply, I apologize. Also, I think you wanted to append your cloned input into div.ai_service?

    In terms of why your original code adds multiple inputs, the cloning process you go through probably first clones one input, adds it, clones the whole thing again (2 inputs), adds 2, and so on. You can use $().eq(0) to limit your jQuery object to the first element it finds that matches your selector.

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

Sidebar

Related Questions

I've got two branches that are fully merged together. However, after the merge is
After two years of C#, my VB.NET is a bit rusty. I have two
I had a problem with committing changes after merging two branches of my project
I work on a large project in Delphi 5. Today, after merging two branches
I am looking to setup a transition between two levels(after one level is complete,
After having looked at each of these two projects, it seems that both are
I have two tables (in postgres) - ads and logs. After every insert into
After reading this question , I was reminded of when I was taught Java
After posting this: Custom Header in GridView ...I have a related problem. I have
I'm adding mouse rotation to my 2D drawing program. I've got all the code

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.