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>
  • 相关阅读:
    定时器
    Vue CLI环境变量
    负数的二进制表示方法
    IDEA指定启动JDK版本
    Windows7安装两个jdk配置
    Bloom Filter 数据结构去重
    新浪微博爬虫参考
    Spring Data JPA
    Spring的JDBC框架
    数据库连接池:Druid
  • 原文地址:https://www.cnblogs.com/bianzhuo/p/9925256.html
Copyright © 2011-2022 走看看