Checkbox checked when page loads
Checkbox checked when page loads making input text disabled.
HTML
<input type="checkbox" id="checkbox" />
<input type="text" id="textInput" />
JavaScript
// Checkbox checked and input disbaled when page loads
$('#checkbox').prop( 'checked', true );
if ($('#checkbox').is(':checked') == true){
$('#textInput').prop('disabled', true);
}
// Enable-Disable text input when checkbox is checked or unchecked
$('#checkbox').change(function(){
if ($('#checkbox').is(':checked') == true){
$('#textInput').prop('disabled', true);
} else {
$('#textInput').val('').prop('disabled', false);
}
});