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

96
Vistas
Disabled attribute not being removed when checkbox is unchecked with jQuery

The script below will add the disabled attribute to other input fields when #alt_hp field is checked, but when I uncheck the field, the disabled attribute does not get removed. I am not that versed in javascript and tried to make sense of other solutions on this site.

<script>
$("#alt_hp").change(function() {
    if ($("input[type=checkbox]").is( ":checked" )) {
        $("#new_displacement").val('')
        $("input#induction, input#heads, input#camshaft, input#turbo, input#boost, input#inc_displacement").prop("checked", false).prop("disabled", true)
    } else {
        $("input#induction, input#heads, input#camshaft, input#turbo, input#boost, input#inc_displacement").prop("disabled", false)
    }
});
</script> 
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Just change below line

if ($("input[type=checkbox]").is( ":checked" )) {

to this

if ($(this).is(":checked")) {

Your existing code will always refer to any/all checkbox in the whole html. this refers to the current checkbox/element.

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