zoukankan      html  css  js  c++  java
  • jquery实现全选 反选 取消

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
        <input type="button" value="全选" onclick="checkAll()">
        <input type="button" value="反选" onclick="reserveAll()">
        <input type="button" value="取消" onclick="cancleAll()">
        <table border="1">
            <thread>
                <th>选项</th>
                <th>姓名</th>
                <th>学号</th>
            </thread>
            <tbody>
                <tr>
                    <td><input type="checkbox"></td>
                    <td>大眼侠</td>
                    <td>1001</td>
                </tr>
                <tr>
                    <td><input type="checkbox"></td>
                    <td>大眼侠</td>
                    <td>1001</td>
                </tr>
                <tr>
                    <td><input type="checkbox"></td>
                    <td>大眼侠</td>
                    <td>1001</td>
                </tr>
                <tr>
                    <td><input type="checkbox"></td>
                    <td>大眼侠</td>
                    <td>1001</td>
                </tr>
                <tr>
                    <td><input type="checkbox"></td>
                    <td>大眼侠</td>
                    <td>1001</td>
                </tr>
            </tbody>
        </table>
        <script src="jquery1.9.js"></script>
        <script>
    
            function checkAll() {
                $(":checkbox").prop("checked",true);
            }
            function  cancleAll() {
                $(":checkbox").prop('checked',false);
            }
            function reserveAll() {
                $(":checkbox").each(function () {
                    var v=$(this.checked)? false:true;
                    $(this).prop('checked',v);
                })
            }
    
        </script>
    </body>
    </html>
  • 相关阅读:
    《Spring_Four》第二次作业 基于Jsoup的大学生考试信息展示系统开题报告
    《Spring_Four》第一次作业:团队亮相
    4.11jsp
    4.7jsp
    3.17jsp
    3.24jsp
    3.10jsp
    3.4软件测试
    回文串
    博客园第二次作业
  • 原文地址:https://www.cnblogs.com/bianzhuo/p/9925256.html
Copyright © 2011-2022 走看看