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

335
Views
¿Cómo ocultar las casillas de verificación que no están marcadas?

¿Hay alguna manera de ocultar las casillas de verificación que no están marcadas? Tengo tres casillas de verificación y estoy buscando una forma de ocultar las que no están marcadas. El código que tengo ahora oculta todas las casillas de verificación y estoy tratando de ocultar las que no están marcadas.

Este es mi código:

 $('input[type=checkbox]').each(function () { //Check if the box is checked var x = $(this).is(':checked'); //if checkbox is NOT checked if(x === false) { //Hide the choice $(this).parent().hide(); } });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <input type="checkbox" name="testing" value="B">A</label><br /> <input type="checkbox" name="testing" value="I">B</label><br /> <input type="checkbox" name="testing" value="A">C</label><br />

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

@ 5alidshammout tiene razón. Necesita un evento de cambio y si desea mostrar todo nuevamente al desmarcar esa casilla, simplemente puede usar la instrucción if. También faltaban etiquetas iniciales para <label> en su código.

 $('input[type=checkbox]').on('change', function() { if ($(this).is(':checked')) { $('input[type=checkbox]').each(function() { //Check if the box is checked var x = $(this).is(':checked'); //if checkbox is NOT checked if(x === false) { //Hide the choice $(this).parent().hide(); } }); } else { $('input[type=checkbox]').parent().show(); } });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <label><input type="checkbox" name="testing" value="B">A</label><br /> <label><input type="checkbox" name="testing" value="I">B</label><br /> <label><input type="checkbox" name="testing" value="A">C</label><br />

about 4 years ago · Juan Pablo Isaza Report

0

Puede verificar si una casilla de verificación está marcada o no con esto:

 if (document.getElementById('testing').checked) { //something }
about 4 years ago · Juan Pablo Isaza Report

0

Puedes probar esto,

 // Hide the choice $(this).hide();

En vez de,

 // Hide the choice $(this).parent().hide();
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!