Html+css+js

Source: Internet
Author: User

1. Get a single checkbox check (three notation) $ ("input:checkbox:checked"). Val () or $ ("input:[type= ' checkbox ']:checked"). Val (); or $ ("input:[name= ' ck ']:checked"). Val ();

2. Get multiple checkboxes checked items $ (' Input:checkbox '). each (function () {if ($ (). attr (' checked ') ==true) {         Alert (This). Val ()); } });

3. Set the first checkbox to a check value of $ (' Input:checkbox:first '). attr ("Checked", ' checked '); or $ (' Input:checkbox '). EQ (0). attr ("Checked", ' true ');

4. Set the last checkbox to the check value $ (' input:radio:last '). attr (' checked ', ' checked '); or $ (' input:radio:last '). attr (' checked ', ' true ');

5. Set any checkbox according to the index value to the check value $ (' Input:checkbox). EQ (index value). attr (' checked ', ' true '); index value =0,1,2 .... or $ (' Input:radio '). Slice. attr (' checked ', ' true ');

6. Select multiple checkboxes to select the checkbox $ (' Input:radio ') for both 1th and 2nd. Slice (0,2). attr (' checked ', ' true ');

7. Set the checkbox to the value value $ ("input:checkbox[value= ' 1"). attr (' checked ', ' true ');

8. Delete the Value=1 checkbox $ ("input:checkbox[value= ' 1 ')". Remove ();

9. Delete the first few checkboxes $ ("Input:checkbox"). EQ (index value). Remove (); index value =0,1,2 .... Delete the 3rd checkbox: $ ("Input:checkbox"). EQ (2). Remove ();

10. Traverse checkbox $ (' Input:checkbox '). each (function (index, Domele) {//write code});

11. Select All $ (' Input:checkbox '). each (function () {$ (this). attr (' checked ', true);});

12. Deselect all $ (' Input:checkbox '). each (function () {$ (this). attr (' checked ', false);});

Html+css+js

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.