I'm trying to disable the Date field on uncheck checkbox and vice-versa.
http://jsfiddle.net/MyNameIsSakthi/ZKw9x/2/
Also this works differently in different browsers!
$('#certExpiry').click(function(){
if($('#certExpiry').is(':checked')){
alert('checked');
$('#expiryDate').removeProp('disabled');
}
else
alert('uncheck');
$('#expiryDate').prop('disabled',true);
});
You probably want something like this...
$('#certExpiry').click(function () {
$('#expiryDate').prop('disabled', !this.checked);
});
jsFiddle .
Also, don't use removeProp()
like that. The documentation makes this clear...
Note: Do not use this method to remove native properties such as
checked
,disabled
, orselected
. This will remove the property completely and, once removed, cannot be added again to element. Use.prop()
to set these properties tofalse
instead.
You forgot to put your else
code in brackets {}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.