I am developing jquery based application. I have one asp.net gridview with checkboxes in every row. I want to check if any of the checkboxes checked or not. I am looping through gridview rows and checking any checkbox is checked or not as below.
var ResultArrayFirst = [];
$('#<%= gdvRegretletter.ClientID %> input[type="hidden"]').each(function () {
if ($(this).closest('tr').find('input[type="checkbox"]').prop('checked', true))
{
ResultArrayFirst.push($(this).val());
}
});
alert(ResultArrayFirst);
To check if a checkbox is checked, use this:
if (checkbox.is(':checked')) {
// Do your stuff
}
So, change your code like this:
if ($(this).closest('tr').find('input[type="checkbox"]').is(':checked'))
{
ResultArrayFirst.push($(this).val());
}