The script is working fine however I am wondering if there is a way to avoid the repetition in the code (DRY method).
JS code:
// 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);
}
});
Aucun commentaire:
Enregistrer un commentaire