vendredi 11 septembre 2015

Checkbox button disabled not working in JQuery

I'm trying to enable and disable a button when a checkbox gets checked, but can't seem to get it working. The button doesn't enable when I check the checkbox.

$("input[type=checkbox]").on("click", function() {
  var id = $(this).data("studentcheckboxid");
  var button = $("div").find("[data-studentbuttonid='" + id + "']");
  $(button).prop('disabled', false);
});
<div class="row registerColumns">
  <div class="col-md-6 col-sm-6" style="border: 1px solid brown;">
    <div id="acceptBox" style="padding: 5px; margin: 5px; border: 1px solid black;">
      Accept
      <input type="checkbox" class="studentCheckbox" data-studentcheckboxid=@space.EventId>
    </div>
  </div>
  <div class="col-md-6 col-sm-6" style="border: 1px solid red;">
    <div class="btn btn-primary disabled registerStudent" data-studentbuttonid=@space.EventId style="padding: 5px; margin: 5px; border: 1px solid black;">
      Register Student
    </div>
  </div>
</div>



Aucun commentaire:

Enregistrer un commentaire