jquery Select CheckBox Method Code Instance

Source: Internet
Author: User
Tags bind min xmlns

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 &lt;! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "&gt; &lt;html xmlns=" http://www.w3.org/1999/xhtml "&gt; &lt;head runat=" Server "&gt; &lt;title&gt;&lt;/title&gt; &lt; Style type= "text/css" &gt; table {border-collapse:collapse} td {Border:1px solid #ccc;} &lt;/style&gt; &lt;script sr C= "Scripts/jquery-1.7.min.js" type= "Text/javascript" &gt;&lt;/script&gt; &lt;script type= "Text/javascript" &gt; $ ( function () {//Chkall all Events $ ("#chkAll"). Bind ("click", Function () {$ ("[name = Chkitem]:checkbox"). attr ("Checked", THIS.C hecked); }); &nbsp;//Chkitem Event $ ("[name = Chkitem]:checkbox"). Bind ("click", Function () {var $chk = $ ("[name = Chkitem]:checkbox"); $ ("#chkAll"). attr ("Checked", $chk. Length = = $chk. Filter (": Checked"). length); }) }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;table id= "TB" &gt; &lt;thead&gt; &lt;tr&gt; &lt;td&gt; &lt;input id= " Chkall "type=" checkbox "/&gt; &lt;/td&gt; &lt;td&gt; category name &lt;/td&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt; &lt;input name= "Chkitem" type= "checkbox" value= "topic of the Day" &gt; &lt;/td&gt; &lt;td&gt; today's topic &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;input name= "Chkitem" type= "checkbox" V Alue= "visual Focus"/&gt; &lt;/td&gt; &lt;td&gt; Visual Focus &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;input name= "Chkitem" type = "checkbox" value= "Finance"/&gt; &lt;/td&gt; &lt;td&gt; finance &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;input name= "Chki Tem "type=" checkbox "value=" Auto "/&gt; &lt;/td&gt; &lt;td&gt; auto &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;input na Me= "Chkitem" type= "checkbox" value= "Technology"/&gt; &lt;/td&gt; &lt;td&gt; technology &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; ; input name= "Chkitem" type= "checkbox" value= "real Estate"/&gt; &lt;/td&gt; &lt;td&gt; Real Estate &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;t d&gt; &lt;input name= "Chkitem" type= "checkbox" value= "Travel"/&gt; &lt;/td&gt; &lt;td&gt; tourism &lt;/td&gt; &lt;/tr&gt; &LT;/TB Ody&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt;
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.