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>

  • 相关阅读:
    macOS免费的NTFS读写软件
    Python模块和模块引用(一)
    Python Class (一)
    Ubuntu系统管理systemd
    Case Closed?
    The 'with' and 'as' Keywords
    Buffering Data
    rstrip
    堆排序
    堆 续9
  • 原文地址:https://www.cnblogs.com/tdmins/p/9494120.html
Copyright © 2011-2022 走看看