jeudi 22 avril 2021

How to update disabled prop on checkbox change?

I have a checkbox that I'm using to toggle whether a li tag gets added to a list. When it is added to the list other li tags and their associated checkboxes (nested under the li tag) are "disabled" using jQuery.

The checkbox will become disabled but it does not un disable when I uncheck the box currently.

I've tried prop, attr, removeProp/Attr which no success in making the checkbox active again.

$('#id_of_ul_that_holds_li's').on('change', li.active input, function() {

    if ($(this).prop('checked')) {
      $(this).parent().addClasss('checked')
      $(this).children('input').prop('disabled', true)
    }
    else if (!($(this).prop('checked')) {
      $(this).parent().removeClasss('checked')
      $(this).children('input').prop('disabled', false)
    }

  });



Aucun commentaire:

Enregistrer un commentaire