zoukankan      html  css  js  c++  java
  • jquery下的正反选操作

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>jquery正反选</title>
    </head>
    <body>
    <button onclick='selectall()'>全选</button>
    <button onclick="cancel()">取消</button>
    <button onclick="reverse()">反选</button>
    <table border="1">
        <tr>
            <td><input type="checkbox"></td>
            <td>111</td>
        </tr>
        <tr>
            <td><input type="checkbox"></td>
            <td>222</td>
        </tr>
        <tr>
            <td><input type="checkbox"></td>
            <td>333</td>
        </tr>
    </table>
    <script src="/static/jquery.min.js"></script>
    <script>
        function selectall() {
            $(':checkbox').each(function () {
                $(this).prop('checked', true)
            })
    
        }
        function cancel() {
            $(':checkbox').each(function () {
                $(this).prop('checked', false)
            })
        }
        function reverse() {
            $(':checkbox').each(function () {
                if ($(this).prop('checked')){
                    $(this).prop('checked', false)
                }
                else {
                    $(this).prop('checked', true)
                }
            })
    
        }
    </script>
    </body>
    </html>
    
  • 相关阅读:
    gitlab 重置密码
    _string 灵活查询
    删除前面,删除后面
    HTTPS
    PHP正则匹配价格
    PHP LUHN算法验证银行卡
    PHP 与操作判断奇偶
    PHP与Cookie
    检查字符串是否存在
    php密码正则匹配
  • 原文地址:https://www.cnblogs.com/wangyue0925/p/9182749.html
Copyright © 2011-2022 走看看