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

100
Views
cómo marcar la casilla de verificación creada dinámicamente está marcada usando jquery
$("input[type='checkbox']").change(function(){ if(this.checked){ if($(':checkbox:checked').length>1 && $('#qT').val()==1){ $(this).prop( "checked", false ); } } });

este es el script para ejecutar y html se ve a continuación

 <div class=row>.... <div class="isCorrect"> <span>correct</span> <input type="checkbox" class="form-check-input mx-1"value="1"> </div>...</div> <div class=row>.... <div class="isCorrect"> <span>correct</span> <input type="checkbox" class="form-check-input mx-1"value="1"> </div>...</div> etc etc

Este código solo marca la primera casilla de verificación. no cualquier otro .. también probé

 $("input[type='checkbox']").change(function(){ if(this.checked){ if($(':checkbox:checked').length>1 && $('#qT').val()==1){ $(this).prop( "checked", false ); } } }).triger(change);

y muchas otras maneras

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

0

Su código no funciona porque su controlador de eventos se crea antes que las casillas de verificación dinámicas. Para omitir esto, puede vincular un controlador de eventos a todo el documento o, para un mejor rendimiento, al principal que contiene todas sus casillas de verificación:

 $(document).on('change',"input[type='checkbox']",function () { // your code here... });
about 4 years ago · Juan Pablo Isaza Report

0

Esto debería funcionar.

Cuando se trata de elementos dinámicos, debe iniciar su selector con un elemento que no sea dinámico y que ya esté en la página. Me gusta usar el método on cuando trato con eventos porque te da más control. Como puede ver, defino el evento y luego selecciono el elemento dinámico al que me dirijo.

Aquí hay otra referencia.

 $("document").on("change", "input", function(){ if($(this).checked && $('#qT').val()==1){ $(this).prop( "checked", false ); } });
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!