js多選全選

來源:互聯網
上載者:User

標籤:round   button   javascrip   alt   name   ble   ext   false   click   

 1 <style type="text/css"> 2         table { 3             width: 800px; 4             text-align: left; 5             border-collapse: collapse; 6         } 7  8         td, th { 9             padding: 10px;10             border: 1px solid black;11         }12     </style>13     <script type="text/javascript">14 15 16       //        反選17       function choose(tag) {18         var inputs = document.getElementsByTagName("input");19         //全選20         for (var i = 0; i < inputs.length - 3; i++) {21           var inputNode = inputs[i];22           if (tag === 1) {23             if (!inputs[i].checked) {24               inputs[i].checked = true;25             }26             //全不選27           } else if (tag === -1) {28             if (inputNode.checked) {29               inputNode.checked = false;30             }31           } else {32             //反選33             inputs[i].checked = !inputs[i].checked;34           }35         }36       }37     </script>38 </head>39 <body>40 <table cellpadding="2" id="tableId">41     <tr>42         <th>43             選擇44         </th>45         <th>46             姓名47         </th>48         <th>49             年齡50         </th>51     </tr>52     <tr>53         <td>54             <label>55                 <input type="checkbox">56             </label>57         </td>58         <td>59             張三60         </td>61         <td>62             1963         </td>64     </tr>65     <tr>66         <td>67             <input type="checkbox">68         </td>69         <td>70             李四71         </td>72         <td>73             1874         </td>75     </tr>76     <tr>77         <td>78             <input type="checkbox">79         </td>80         <td>81             張三82         </td>83         <td>84             1885         </td>86     </tr>87     <tr>88         <td colspan="3">89             <input type="button" onclick="choose(1)" value="全選">90             <input type="button" onclick="choose(-1)" value="全不選">91             <input type="button" onclick="choose(0)" value="反選">92         </td>93     </tr>94 </table>

js多選全選

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.