Smudger
Smudger

Reputation: 10781

javascript to enable checkbox and check it

I remove the check and disable a checkbox with:

$('#h12_1').removeAttr('checked');
$("#h12_1").prop("disabled", true); 

I then want to enable it again and then check it.

$('#h12_1').removeAttr('disabled');
$('#h12_1').attr('checked','checked');

The above syntax reenables the checkbox but does not check it.

Am I missing something? help appreciated as always.

Upvotes: 1

Views: 58

Answers (1)

Sachin
Sachin

Reputation: 40970

instead of this

$('#h12_1').attr('checked','checked');

try something like this

$('#h12_1').prop("checked",true);

Upvotes: 3

Related Questions