I am using Jquery to disable and re-enable a text area depending on whether a checkbox is checked or not.
I am able to disable the text area box when checkbox is checked, but unable to enable it when checkbox is unchecked. Here is my current Jquery script:
$('#business_closed').change(function(){
value = $(this).val();
console.log(value);
if(value){
$('#open_hours').attr("disabled", "disabled");
}
else{
$('#open_hours').removeAttr("disabled");
}
return false;
});
Based on console.log(value);, my value is always 1 even when I am unchecking the checkbox. How do I get the value of the checkbox (whether or not it is checked)?
Thanks.
Modified code: You should use checked properties