2011-08-12 18 views
0

我們如何驗證在GridView的每一行中是否都選中了複選框。以下代碼不起作用。查找GridViewRow中的複選框

   $("#btnComplete").click(
          function(e) { 
           $("#<%=grdCustDetails.ClientID%> tr").each(function() { 
            //Skip first(header) row 
            if (!this.rowIndex) return; 


            if ($(this).find('input:checkbox:checked').checked > 0) { 
             alert("your check box in this row is checked"); 
            } 



           }); 

       }); 
+0

有在GridView的每一行與chkSel命名的複選框。 – CodeNinja

回答

1

試試這個

if ($(this).find('input:checkbox:checked').length > 0) { 
    alert("your check box in this row is checked"); 
} 

您還可以使用is方法這樣

if ($(this).find('input:checkbox').is(':checked')) { 
    alert("your check box in this row is checked"); 
} 
+0

第二個解決方案像魅力一樣工作!非常感謝shankar! – CodeNinja