This article mainly introduces jquery selected CheckBox method code example (select all, inverse, all do not select), this article directly gives code examples, the need for friends can refer to the following
1. CheckBox List Selection
Code:
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55-56 |
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> |
2, CheckBox table selected
Effect Chart:
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 5 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns=" http://www.w3.org/1999/xhtml "> <head runat=" Server "> <title></title> < Style type= "text/css" > table {border-collapse:collapse} td {Border:1px solid #ccc;} </style> <script sr C= "Scripts/jquery-1.7.min.js" type= "Text/javascript" ></script> <script type= "Text/javascript" > $ ( function () {//Chkall all Events $ ("#chkAll"). Bind ("click", Function () {$ ("[name = Chkitem]:checkbox"). attr ("Checked", THIS.C hecked); }); //Chkitem Event $ ("[name = Chkitem]:checkbox"). Bind ("click", Function () {var $chk = $ ("[name = Chkitem]:checkbox"); $ ("#chkAll"). attr ("Checked", $chk. Length = = $chk. Filter (": Checked"). length); }) }); </script> </head> <body> <table id= "TB" > <thead> <tr> <td> <input id= " Chkall "type=" checkbox "/> </td> <td> category name </td> </tr> </thead> <tbody> <tr> <td> <input name= "Chkitem" type= "checkbox" value= "topic of the Day" > </td> <td> today's topic </td> </tr> <tr> <td> <input name= "Chkitem" type= "checkbox" V Alue= "visual Focus"/> </td> <td> Visual Focus </td> </tr> <tr> <td> <input name= "Chkitem" type = "checkbox" value= "Finance"/> </td> <td> finance </td> </tr> <tr> <td> <input name= "Chki Tem "type=" checkbox "value=" Auto "/> </td> <td> auto </td> </tr> <tr> <td> <input na Me= "Chkitem" type= "checkbox" value= "Technology"/> </td> <td> technology </td> </tr> <tr> <td> ; input name= "Chkitem" type= "checkbox" value= "real Estate"/> </td> <td> Real Estate </td> </tr> <tr> <t d> <input name= "Chkitem" type= "checkbox" value= "Travel"/> </td> <td> tourism </td> </tr> </TB Ody> </table> </body> </html> |