Since jQuery 1.6, Thethe behavior of jQuery.attr()
has changed and users are encouraged not to use it to retrieve an element's checked state. Instead, you should use jQuery.prop()
:
$("#txtAge").toggle(
$("#isAgeSelected").prop("checked") // forFor checked attribute it returns true/false;
// returnReturn value changes with checkbox state
);
Two other possibilities are:
$("#txtAge").get(0).checked
$("#txtAge").is(":checked")