zoukankan      html  css  js  c++  java
  • 复选框的自定义操作

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     5     <title></title>
     6     <meta charset="utf-8" />
     7     <link rel="stylesheet" href="style/style.css">
     8     <script src="js/jquery-1.10.2.min.js"></script>
     9     <script src="js/cjDome.js"></script>
    10     <script src="js/dome9.js"></script>
    11     <style>
    12          .ck lable{
    13              16px;
    14              height:16px;
    15              border:1px solid #ccc;
    16              border-radius:4px;
    17              display:inline-block;
    18          }
    19          .active{
    20              background:#2A9FF6;
    21          }
    22          .ck input{
    23              display:none;
    24          }
    25     </style>
    26     <script>
    27         $(function () {
    28             $(".ck lable").click(function () {
    29                 if ($(this).index() == 0) {//全反选
    30                     if($(this).find("input").is(":checked")){
    31                         $(".ck").find("input").prop("checked", false);
    32                         $(".ck").find("lable").removeClass("active")
    33                     }
    34                     else {//全选
    35                         $(".ck").find("input").prop("checked", true);
    36                         $(".ck").find("lable").addClass("active")
    37                     }
    38                 } else {//单反选
    39                     if ($(this).find("input").is(":checked")) {
    40                         $(this).find("input").prop("checked", false);
    41                         $(this).removeClass("active")
    42                     } else {//单选
    43                         $(this).find("input").prop("checked", true);
    44                         $(this).addClass("active")
    45                     }
    46                 }
    47             })
    48             
    49         })
    50     </script>
    51 </head>
    52 <body>
    53     <div class="ck">
    54         全选<lable>
    55            <input type="checkbox" />
    56         </lable>
    57         1<lable>
    58             <input type="checkbox" />
    59         </lable>
    60         2<lable>
    61             <input type="checkbox" />
    62         </lable>
    63         3<lable>
    64             <input type="checkbox" />
    65         </lable>
    66         4<lable>
    67             <input type="checkbox" />
    68         </lable>
    69     </div>
    70 </body>
    71 </html>

  • 相关阅读:
    SecureCRT 迁移到新环境,配置导出
    Git 常用操作
    Java 性能分析工具 Asyncprofiler
    冒号语法
    后台乱码转中文
    js讲解视频
    下载指定版本的loader.调整文件夹结构
    react大型数据渲染列表
    git拉取报错
    记录一个排序表格的插件
  • 原文地址:https://www.cnblogs.com/sunnie-cc/p/6117890.html
Copyright © 2011-2022 走看看