zoukankan      html  css  js  c++  java
  • s2选择框的全选和反选jQuery

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    <div>
        <input type="button" value="全选" onclick="allSelect()">
        <input type="button" value="反选" onclick="reverseSelect()">
        <input type="button" value="取消" onclick="deleteSelect()">
    </div>
    <table border="1">
        <thead>
             <tr>
                 <th>选择</th>
                 <th>ip</th>
                 <th>post</th>
             </tr>
    
        </thead>
        <tbody id="tb">
             <tr>
                 <td><input type="checkbox"></td>
                 <td>1.1.1.1</td>
                 <td>80</td>
             </tr>
             <tr>
                 <td><input type="checkbox"></td>
                 <td>1.1.1.1</td>
                 <td>80</td>
             </tr>
             <tr>
                 <td><input type="checkbox"></td>
                 <td>1.1.1.1</td>
                 <td>80</td>
             </tr>
    
        </tbody>
    
    </table>
    <script src="../jquery-2.12.4.js"></script>
    <script>
        function allSelect() {
            var v=$('#tb input[type="checkbox"]');
            console.log(v);
            v.prop('checked', true)
        }
        function deleteSelect() {
            var v = $('#tb input[type="checkbox"]');
            v.prop('checked', false)
    
        }
        function reverseSelect() {
            $('#tb input[type="checkbox"]').each(function () {
                if($(this).prop('checked')){
                    $(this).prop('checked', false);
                }
                else{
                     $(this).prop('checked', true);
                }
            })
        }
    </script>
    
    </body>
    </html>
  • 相关阅读:
    解题:POI 2008 Plot purchase
    1807. 斐波纳契数列简单
    1745. 单调数列
    1700. 增减字符串匹配
    1665. 计算数字
    1523. 分区数组
    1517. 最大子数组
    1598. 两句话中的不常见单词
    1594. 公平的糖果交换
    1510. 亲密字符串(回顾)
  • 原文地址:https://www.cnblogs.com/my-love-is-python/p/9307814.html
Copyright © 2011-2022 走看看