How do I disable a field by clicking the checkbox option?
How do I disable a field by clicking the checkbox option?
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.