<address id="ttjl9"></address>

      <noframes id="ttjl9"><address id="ttjl9"><nobr id="ttjl9"></nobr></address>
      <form id="ttjl9"></form>
        <em id="ttjl9"><span id="ttjl9"></span></em>
        <address id="ttjl9"></address>

          <noframes id="ttjl9"><form id="ttjl9"></form>

          jquery 關于table的全選與反選

          2018-7-3    seo達人

          如果您想訂閱本博客內容,每天自動發到您的郵箱中, 請點這里

          控制表格的多選和反選,直接上代碼,順便安利一個小知識點:tr的底邊框不顯示的問題,解決辦法是:table{border-collapse:collapse;}    

          
          
          1. <!DOCTYPE html>
          2. <html>
          3. <head>
          4. <title></title>
          5. <style>
          6. *{margin:0;padding:0;}
          7. table{border-collapse:collapse}
          8. .detail_tb {width: 100%;border: 1px solid #ccc;}
          9. .detail_tb .fied_header {height: 38px;line-height: 38px;border-left: none;border-bottom: 1px solid #ccc;background-color: #ececec;}
          10. .detail_tb .fied_header th {text-align: center;border-right: 1px solid #ccc;color: #333;font-size: 14px;}
          11. .detail_tb .fied_header th input {vertical-align: middle;}
          12. .detail_tb tr {height: 38px;line-height: 38px;border-left: none;border-bottom: 1px solid #ccc;background-color: #fff;}
          13. .detail_tb tr td {text-align: center;border-right: 1px solid #ccc;color: #666;font-size: 14px;}
          14. .detail_tb tr td input {float: left;margin: 12px 5px 0 10px;}
          15. .detail_tb tr td span {float: left;}
          16. .detail_tb tr td select {display: inline-block;width: 90px;height: 24px;}
          17. </style>
          18. </head>
          19. <body>
          20. <table class="detail_tb" >
          21. <thead>
          22. <tr class="fied_header">
          23. <th width="65"><input type="checkbox" value="number" id="number"> 序號</th>
          24. <th width="110">孩子姓名</th>
          25. <th width="130">家長電話</th>
          26. <th width="110">介紹人孩子姓名</th>
          27. <th width="130">介紹人電話</th>
          28. <th width="150">報名時間</th>
          29. <th width="100">分組情況</th>
          30. <th width="100">拉新數量</th>
          31. <th width="100">是否簽到</th>
          32. <th width="100">是否發獎</th>
          33. </tr>
          34. </thead>
          35. <tbody id="tbody">
          36. <tr>
          37. <td width="65"><input type="checkbox" value="" id="" ><span>1</span></td>
          38. <td width="110">張三</td>
          39. <td width="130">13888888888</td>
          40. <td width="110">李四</td>
          41. <td width="130">13888888888</td>
          42. <td width="150">2016/08/6 21:00</td>
          43. <td width="100">
          44. <select name="" id="">
          45. <option value="">未分組</option>
          46. <option value="">1</option>
          47. <option value="">2</option>
          48. </select>
          49. </td>
          50. <td width="100">33</td>
          51. <td width="100"></td>
          52. <td width="100">
          53. <select name="" id="">
          54. <option value=""></option>
          55. <option value="">獎品1</option>
          56. <option value="">獎品2</option>
          57. </select>
          58. </td>
          59. </tr>
          60. <tr>
          61. <td width="65"><input type="checkbox" value="" id=""><span>2</span></td>
          62. <td width="110">張四</td>
          63. <td width="130">13888888888</td>
          64. <td width="110">李四</td>
          65. <td width="130">13888888888</td>
          66. <td width="150">2016/08/6 21:00</td>
          67. <td width="100">
          68. <select name="" id="">
          69. <option value="">未分組</option>
          70. <option value="">1</option>
          71. <option value="">2</option>
          72. </select>
          73. </td>
          74. <td width="100">33</td>
          75. <td width="100"></td>
          76. <td width="100">
          77. <select name="" id="">
          78. <option value=""></option>
          79. <option value="">獎品1</option>
          80. <option value="">獎品2</option>
          81. </select>
          82. </td>
          83. </tr>
          84. <tbody>
          85. </table>
          86. <script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
          87. <script type="text/javascript">
          88. // 全選和反選
          89. $("#number").click(function () {
          90. var isChecked = $("#number").prop("checked");
          91. $("#tbody input").prop("checked", isChecked);
          92. })
          93. // 單獨選項控制全選
          94. $("#tbody input").click(function () {
          95. var allLength = $("#tbody input").length;
          96. var checkedLength = $("#tbody input:checked").length;
          97. if(allLength == checkedLength){
          98. $("#number").prop("checked",true);
          99. }else {
          100. $("#number").prop("checked",false);
          101. }
          102. });
          103. </script>
          104. </body>
          105. </html>



          藍藍設計www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 平面設計服務


          日歷

          鏈接

          個人資料

          藍藍設計的小編 http://www.syprn.cn

          存檔

          亚洲va欧美va天堂v国产综合