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

136
Views
¿Cómo almacenar los valores de todas las casillas marcadas con el mismo nombre de clase en una matriz?

He revisado todas las publicaciones aquí y ninguna funcionó hasta ahora. Tengo una lista de casillas de verificación con la misma clase:

 <input class="my_checkbox" type="checkbox" value="some_value1"> <input class="my_checkbox" type="checkbox" value="some_value2"> <input class="my_checkbox" type="checkbox" value="some_value3">

Puedo alternarlos individualmente o usar un botón de alternancia que marque/desmarque todo:

 $(document).on('click', '#toggle_button', function () { if ($(this).prop("checked")) { $(".my_checkbox").prop("checked", true); } else { $(".my_checkbox").prop("checked", false); } });

Ahora quiero obtener todos los valores en una matriz, probé varias cosas y ninguna funcionó, la matriz siempre termina vacía.

Lo intenté:

 $('input:checkbox.my_checkbox').each(function () { arr.push($(this).val()); });

y:

 $('.my_checkbox:checkbox:checked').map(function() { arr.push($(this).val()); }).get();

Y algunos más, pero nada parece funcionar

about 4 years ago · Juan Pablo Isaza
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!