select all checkbox in table using jquery





<html>
<head>

<script type="text/javascript" src="Jquery.1.10.2.js"></script>
   <script type="text/javascript">
       $(document).ready(function () {

           $('#selectall').click(function (event) {
               if (this.checked) {
                   $('.chkval').each(function () {
                       this.checked = true;
                   });
               }
               else {
                   $('.chkval').each(function () {
                       this.checked = false;
                   });
               }
           });
       });
</script>

</head>
<body>
<table id="tblhd" border="1" style="width:100%;">
                           
           <tr>
             <td><input type="checkbox" id="selectall" />Select</td>

             <td>Players</td>
           </tr>
                   
           <tr>
             <td><input type='checkbox' name='chksingle' class='chkval' value='Sachin'></td>
             <td>Dravid</td> 

           </tr>
           <tr>
              <td><input type='checkbox' name='chksingle' class='chkval' value='Shewag'></td>
               <td>Shewag</td>        
            </tr>
           <tr>
             <td><input type='checkbox' name='chksingle' class='chkval' value='Dravid'></td>
             <td>Dravid</td>        
           </tr>
       </table>
</body>
</html>


Comments

Popular posts from this blog

Unable to perform operation on the item is locked in workspace

Maximum Stored Procedure Function Trigger or View Nesting Level Exceeded (limit 32) in SQL Server

Insecure cookie setting: missing Secure flag