[Jquery] checkbox -- similar to the full mailbox selection function (jquery Version)

Source: Internet
Author: User

Previously, I used Native js to write checkbox-similar to the full mailbox selection function,Click here. Recently I am studying jquery. Today I am taking the time to use jquery to write a checkbox-similar to the full mailbox selection function.

 <!  Doctype html  >  <  Html  Lang  = "En-us"  >  <  Head  >      <  Meta  Charset = "UTF-8"  >      <  Title  > Checkbox </  Title  >  </  Head  >  <  Body  >      <  Input  Type = "Checkbox"  Name  = "BTN"  ID  = "BTN"  /> <  Label  For  = "BTN"  > Select All/do not select all </  Label  > <  BR  />      <  Input Type  = "Checkbox"  Name  = "Choose"  ID  = "Checkbox1"  /> <  Label  For  = "Checkbox1"  > Option 1 </  Label  > <  BR  />      < Input  Type  = "Checkbox"  Name  = "Choose"  ID  = "Checkbox2"  /> <  Label  For  = "Checkbox2"  > Option 2 </  Label  > <  BR  />     <  Input  Type  = "Checkbox"  Name  = "Choose"  ID  = "Checkbox3"  /> <  Label  For  = "Checkbox3"  > Option 3 </  Label  > <  BR />      <  Input  Type  = "Checkbox"  Name  = "Choose"  ID  = "Checkbox4"  /> <  Label  For  = "Checkbox4"  > Option 4 </  Label  > < BR  />      <  Input  Type  = "Checkbox"  Name  = "Choose"  ID  = "Checkbox5"  /> <  Label  For  = "Checkbox5"  > Option 5 </  Label > <  BR  />      <  Input  Type  = "Checkbox"  Name  = "Choose"  ID  = "Checkbox6"  /> <  Label  For  = "Checkbox6"  > Option 6 </ Label  > <  BR  />      <  Input  Type  = "Checkbox"  Name  = "Choose"  ID  = "Checkbox7"  /> <  Label  For  = "Checkbox7"  > Option 7</  Label  > <  BR  />      <  Input  Type  = "Checkbox"  Name  = "Choose"  ID  = "Checkbox8"  /> <  Label  For  = "Checkbox8" > Option 8 </  Label  > <  BR  />      <  Input  Type  = "Checkbox"  Name  = "Choose"  ID  = "Checkbox9"  /> <  Label  For = "Checkbox9"  > Option 9 </  Label  > <  BR  />      <  Input  Type  = "Checkbox"  Name  = "Choose"  ID  = "Checkbox10"  /> <  Label For  = "Checkbox10"  > Option 10 </  Label  > <  BR  />      <  A  Href  = "Javascript :;"  ID  = "Btn2"  > Invert Selection </  A >  </  Body  >  </  Html  >  <  Script  Type  = "Text/JavaScript"  SRC  = "/JS/jquery. Min. js"  > </  Script  >  < Script  Type  = "Text/JavaScript"  >  $ (  Function  (){  VaR  Checkboxes  =  $ (  '  Input [name = choose] '  );  VaR  BTN  =  $ (  '  # BTN  '  );  VaR  Btn2 =  $ (  '  # Btn2  '  ); BTN. Click (  Function  () {Checkboxes. ATTR (  '  Checked  ' ,  This  . Checked) ;}); checkboxes. Click (  Function  (){  VaR  Flag  =   True  ; Checkboxes. Each (  Function (){  If  (  !  This  . Checked) Flag  =   False  ;}); BTN. ATTR (  '  Checked '  , Flag) ;}); btn2.click (  Function  (){  VaR  Flag  =   True  ; Checkboxes. Each (  Function  (){ This  . Checked  =   !  This  . Checked;  If  (  !  This  . Checked) Flag  =  False  ;}); BTN. ATTR (  '  Checked  '  , Flag );});});  </  Script  > 

TIPS: If jquery is used, you need to introduce the jquery library.

PS: The above are some of the effects I have learned through jquery.

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.

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.