1
How do I disable a field by clicking the checkbox option?
1
How do I disable a field by clicking the checkbox option?
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>
<input type="checkbox" id="control" />
<input type="text" id="target" />
Note: The library jQuery
was used.
Thanks Luiz, I had only managed to do the reverse.
Browser other questions tagged javascript html jquery
You are not signed in. Login or sign up in order to post.
You can explain the question better and add HTML?
– Sergio