Skip to content Skip to sidebar Skip to footer

How To Uncheck All Checkboxes When I Close A Modal?

I want to pop up a modal on clicking the checkbox. And wants to uncheck it when I close a modal automatically. I tried both attr and prop methods. None of them worked. //uncheck

Solution 1:

Please use this code I hope it's work for you.

Thanks

$(document).ready(function(){
    $("#myModal").on('hide.bs.modal', function(){
         $('.creditCheckbox').prop('checked', false);
  });
});

Solution 2:

I have to make an example like your code, please review once, hope it will help you, it is working for me. Thanks.

<divclass="container"><inputtype="checkbox"name="check"class="checkOption"> check 1
  <inputtype="checkbox"name="check"class="checkOption"> check 2
  <inputtype="checkbox"name="check"class="checkOption"> check 3
  <inputtype="checkbox"name="check"class="checkOption"> check 4
  <!-- Trigger the modal with a button --><buttontype="button"class="btn btn-info btn-lg"data-toggle="modal"data-target="#cbreInvoiceDetailsModal">Open Modal</button><!--Modal html code--><divclass="modal fade"id="cbreInvoiceDetailsModal"role="dialog"><divclass="modal-dialog modal-lg"role="document"><divclass="modal-content"><divclass="modal-header"><h5class="modal-title">Full screen view</h5><buttontype="button"class="close"data-dismiss="modal"aria-label="Close"><spanaria-hidden="true">&times;</span></button></div><divclass="modal-body"><divclass="col-md-12 col-xs-12 col-sm-7"><divclass="box_layout"id="show-data"><divclass="image_layout"></div></div></div></div><divclass="modal-footer"><buttonid="closeInvoiceModal"type="button"class="btn btn-sm btn-success waves-effect pull-right"data-dismiss="modal">Close</button></div></div></div></div></div><script>
  $(document).ready(function(){
    $("#cbreInvoiceDetailsModal").on('hide.bs.modal', function(){
      $('.checkOption').prop('checked', false);
  });

});
</script>

Post a Comment for "How To Uncheck All Checkboxes When I Close A Modal?"