Disable field when clicking the checkbox [closed]

1

How do I disable a field by clicking the checkbox option?

    
asked by anonymous 14.06.2018 / 23:23

1 answer

2

A simple example to do what you want:

$('#control').on('change', function () {
  $('#target').prop('disabled', $(this).is(':checked'));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><inputtype="checkbox" id="control" />
<input type="text" id="target" />

Note: The library jQuery was used.

    
14.06.2018 / 23:27