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>

  • 相关阅读:
    Linux_C smsh1
    ACM&排序问题,操作符重载
    ACM&找双亲,并查集
    struct dirent/DIR
    关于win8如何查找出当前的密钥
    php之留言板
    php之include&require
    工作中的问题 和 所用到的知识点
    jQuery.extend 和 jQuery.fn.extend
    JavaScript 字符串函数 之查找字符方法(一)
  • 原文地址:https://www.cnblogs.com/tdmins/p/9494120.html
Copyright © 2011-2022 走看看