zoukankan      html  css  js  c++  java
  • checkbox全选jquery

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>selectAll</title>
        <style type="text/css">
           table {
                border: 1px solid red;
                border-collapse:collapse;
                300px;
                margin :auto;
                text-align:center;
                   
                    
    
            }
        </style>
        <script src="js/jquery-1.7.1.js"></script>
      
        <script type="text/javascript">
            $(function () {
                $(".all").click(function () {
                    if ($(".all").attr("checked")) {//全选
                       
                        $(".cc").attr("checked", true);
                    }
                    else {//取消全选
                        $(".cc").removeAttr("checked");
                    }
                   
                })
    
                $(".cc").click(function () {
                    SelectAll();
                })
    
    
            })
    
    
            function SelectAll() {
                
                if (!$(".cc").attr("checked")) {//未选中
                    $(".all").attr("checked",false)
                }
                else {//全部选中
                    $(".all").attr("checked", true)
                }
    
    
            }
        </script>
    </head>
    <body>
        <table id="tb" border="1">
            <tr>
                <td>序列</td>
            </tr>
             <tr>
                <td>
                    <input type="checkbox" class="cc"/></td>    </tr>
                  <tr>
                <td><input type="checkbox" class="cc"/></td>
        
            </tr>
             <tr>
                <td><input type="checkbox" class="cc"/></td>
        
            </tr>
             <tr>
                <td><input type="checkbox" class="cc"/></td>
        
            </tr>
             <tr>
                <td><input type="checkbox" class="all"  />all</td>
        
            </tr>
        </table>
    </body>
    </html>
  • 相关阅读:
    es6常用语法(持续更新中)
    发送请求时params和data的区别
    js引擎查询 LHS RHS(消化ing)
    Linux常用命令(持续更新)
    Https理解
    MVVM理解
    原生js与jquery区别
    Cookie如何防范XXS攻击
    基于python的appium环境搭建
    pycharm安装步骤
  • 原文地址:https://www.cnblogs.com/junhuang/p/3960583.html
Copyright © 2011-2022 走看看