Skip to main content
Copy edited.
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 109
  • 132

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")

Since jQuery 1.6, The 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") // for checked attribute it returns true/false;
                                        // return value changes with checkbox state
);                           

Two other possibilities are:

$("#txtAge").get(0).checked
$("#txtAge").is(":checked")

Since jQuery 1.6, the 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") // For checked attribute it returns true/false;
                                        // Return value changes with checkbox state
);

Two other possibilities are:

$("#txtAge").get(0).checked
$("#txtAge").is(":checked")
Post Made Community Wiki by Udit Bhardwaj
added 96 characters in body
Source Link
Salman Arshad
  • 269.9k
  • 83
  • 436
  • 528

Since jQuery 1.6, The 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") // for checked attribute it returns true/false;
                                        // return value changes with checkbox state
);                           

Two other possibilities are:

$("#txtAge").get(0).checked
$("#txtAge").is(":checked")

Since jQuery 1.6, The 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") // for checked attribute it returns true/false;
                                        // return value changes with checkbox state
);                           

Since jQuery 1.6, The 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") // for checked attribute it returns true/false;
                                        // return value changes with checkbox state
);                           

Two other possibilities are:

$("#txtAge").get(0).checked
$("#txtAge").is(":checked")
Source Link
Salman Arshad
  • 269.9k
  • 83
  • 436
  • 528

Since jQuery 1.6, The 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") // for checked attribute it returns true/false;
                                        // return value changes with checkbox state
);