Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

70
Views
Agregar contador jquery

Tengo un problema porque no sé cómo cambiar el código para agregar un contador en la entrada de nombre. Entonces, cuando haga clic en #add_input, la nueva entrada tendrá el nombre name[0], name[1], etc.

 $("#add_input").click(function () { var html = ''; html += '<div class="row">'; html += '<input type="checkbox" name="name[0]">'; html += '</div></div>'; };
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

prueba esto

 let i = 0 $("#add_input").click(() => { i += 1; var html = `<div class="row"> <label><input type="checkbox" name="name[]"> input ${i}</label> </div>`; $('#result').append(html); })
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <button id="add_input">add input</button> <div id="result"></div>

about 4 years ago · Juan Pablo Isaza Report

0

var counter = 0; $("#add_input").click(function () { var html = ''; html += '<div class="row">'; html += '<input type="checkbox" name="name_' + counter + '"/>'; html += '</div>'; counter ++; };
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!