zoukankan      html  css  js  c++  java
  • jquery实现全选等功能

    <script type="text/javascript">
    $(function () {
           // 1.选中第一列的功能大项后,自动选中该行第二列的所有功能小项。
           $(".parentfunc").click(function ()
           {
         //根据.parentfunc的选中状态改变后面的状态
          $(this).parent("span").parent("td").siblings("td").children("span").children("input").prop("checked",$(this).prop("checked"));
      })

         //2.当第二列功能小项没有全部选中时,该行第一列的复选款也要取消选中。
        $("tr td:last-child span input").click(function () {

       var num = 0;
        for (var i = 0; i < $(this).parent().parent().children().length; i++)
      {
        if ($(this).parent().parent().children(":eq("+i+")").children().prop("checked")==false)
        {
          num++;
          $(this).parent("span").parent("td").siblings("td").children("span").children("input").prop("checked", false);
        }
      if(num==0)
      {
        $(this).parent("span").parent("td").siblings("td").children("span").children("input").prop("checked",true);
      }
        }

      })
    })
    </script>

  • 相关阅读:
    select和epoll的区别
    Epoll导致的selector空轮询
    2.集合框架中的泛型有什么优点?
    java的语法基础(二)
    17-文本属性和字体属性
    15-浮动
    16-margin的用法
    14-块级元素和行内元素
    12-简单认识下margin
    day15 什么是递归/递归与回溯
  • 原文地址:https://www.cnblogs.com/tdmins/p/9494120.html
Copyright © 2011-2022 走看看