First, the fiddle.
$('#enableButtonB').click(function (e) {
if($(e.target).is(':checked'))
{
$('#myButtonB').removeProp('disabled');
alert('Enable Button B');
}
else
{
$('#myButtonB').prop('disabled', true);
alert('Disable Button B');
}
});
I'm trying to use jQuery's .prop()
and removeProp()
methods to enable and disable a button based on some criteria. It seems to work fine until removeProp()
is called on the element. After that any subsequent calls to prop()
fail to disable to button.
What's the proper way to enable and disable an element repeatedly?
$('element').prop('disabled', true/false)
where you use true if you want it to be disabled, or false if you want it enabled.removeProp()
in the future.