Jquery - Select All CheckBox

Use the following code to select a list of check boxes using JQuery.

<html>

<script language="javascript">
function toggleSelectAll()
{
       
 $('#selectAll').click(function () {
        $('.selectId').prop('checked', this.checked);
  });

  $('.selectId').change(function () {
        var check = ($('.selectServiceId').filter(":checked").length == $('.selectId').length);
        $('#selectAll').prop("checked", check);
  });
}
</script>

<table  style="width: 1744px;">
    <thead>
        <tr role="row">
            <th rowspan="1" colspan="1" style="width: 30px;" aria-label="">
                <input type="checkbox" id="selectall">Select all</input>
            </th>
            <th tabindex="0" rowspan="1" colspan="1" style="width: 203px;">Type</th>
            <th tabindex="0" rowspan="1" colspan="1" style="width: 354px;">Status</th>
        </tr>
    </thead>
    <tbody role="alert">
        <tr class="results-table-row odd">
            <td align="center">
                <input type="checkbox" class="selectedId" name="selectedId" value="A">
            </td>
        </tr>
        <tr class="results-table-row even">
            <td align="center">
                <input type="checkbox" class="selectedId" name="selectedId" value="1" />
            </td>
            <td>Stop Noted Record</td>
            <td>Open (New)</td>
        </tr>
        <tr class="results-table-row even odd">
            <td align="center" class=" ">
                <input type="checkbox" class="selectedId" name="selectedId" value="2" />
            </td>
           
        </tr>
    </tbody>
</table>

</html>

Search