find if any checkbox is checked in a specific column of the GridView using jQuery
Please let me know how to check if any checkbox is checked in a specific column (for example first column) of the Gr开发者_StackOverflowidView control using jQuery? there are checkboxes in other columns too, but I need to check if any checkbox is checked in a specific column. thanks in advance.
thanks for the reply. solved it myself with help from the following link
if ($("#<%=GridView1.ClientID %> >tbody >tr >td:first-child > input[type=checkbox]:checked").length > 0) {}
http://www.codedigest.com/CodeDigest/63-Check-All-Checkboxes-in-a-Particular-Column-in-GridView-using-JQuery-.aspx
You could do this:
var checked = $('selectorForColumn :checkbox:checked').length > 0;
or this:
var checked = $('selectorForColumn :checkbox').is(':checked');
...which will return true
if at least one checkbox in the column is checked.
Not sure what the proper selector is without seeing your markup, but if it is the first column, you would do something like this:
$('table > tbody > tr > td:first-child :checkbox')
精彩评论