JQuery 全选和全不选的实现

全选和全不选


<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>全选和全不选title>
    <script src="js/jquery-3.4.1.min.js">script>

    <script>
        
        function selectAll(obj){
            $(".itemSelect").prop("checked",obj.checked);
        }

    script>

head>

<body>
    <table border="1px solid black" height="200px" width="500px" align="center">
        <tr>
            <td><input type="checkbox" onclick="selectAll(this)"> td>
            <th>表头th>
            <th>表头th>
            <th>表头th>
        tr>

        <tr>
            <td><input type="checkbox" class="itemSelect"> td>
            <td>数据td>
            <td>数据td>
            <td>数据td>
        tr>
        <tr>
            <td><input type="checkbox" class="itemSelect"> td>
            <td>数据td>
            <td>数据td>
            <td>数据td>

        tr>
        <tr>
            <td> td>
            <td>数据td>
            <td>数据td>
            <td>数据td>

        tr>
        <tr>
            <td><input type="checkbox" class="itemSelect"> td>
            <td>数据td>
            <td>数据td>
            <td>数据td>

        tr>

    table>
body>
html>

你可能感兴趣的:(JQuery)