Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

95
Vistas
how to check dynamically created checkbox is checked using jquery
$("input[type='checkbox']").change(function(){
  if(this.checked){
    if($(':checkbox:checked').length>1 && $('#qT').val()==1){
        $(this).prop( "checked", false );
    }
  }
});

this is the script to run And html looks like below

<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

This code only checks the first check box. not any other.. I also tried

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

and many other ways

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Your code is not working because your event handler is created before the dynamic checkboxes are. To bypass this, you can bind an event handler to the whole document or, for better performance, to the parent that contains all your checkboxes :

$(document).on('change',"input[type='checkbox']",function () {

    // your code here...

});
about 4 years ago · Juan Pablo Isaza Denunciar

0

This should work.

When dealing with dynamic elements you have to start your selector with an element that is not dynamic and is already on the page. I like using the on method when dealing with events because it gives you more control. As you see I then define the event and then select the dynamic element that I am targeting.

Here is another reference.

$("document").on("change", "input", function(){
  if($(this).checked && $('#qT').val()==1){
     $(this).prop( "checked", false );
  }
});
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda