Thursday, July 5, 2012

Asp.Net jQuery checkbox get checked state


In this post Asp.Net jQuery checkbox get checked state, we shall see on how to get the checked state of a checkbox using jQuery.

We can get the checked state of a checkbox using any one of the 3 syntaxes specified bellow.

alert($('#chkStatus').attr('checked') ? true : false);
alert($('#chkStatus:checked').val() ? true : false);
alert($('#chkStatus:checked').is(':checked'));

To set the checked status, on click of a button uses the following script.

// Get Status of CheckBox
$('#cmdGetCheckedStatus').click(function(event) {
    event.preventDefault();
    alert($('#chkStatus:checked').is(':checked'));
});


Search Flipkart Products:
Flipkart.com

No comments: