Discussion on jquery setting and obtaining checkbox selection _jquery

Source: Internet
Author: User

1. Set checkbox check:

Select multiple marquee
checkbox=$ ("#agentinfo input[name= ' veri[]");

Loop the value
Checkbox.each (function () {for
              
  (var j=0;j<data.veri.length;j++) {
    
    ////To determine if the current value is in an array
    . (this). val () = = Data.veri[j]) {
      $ (this). attr (' checked ', ' checked ');//Check
    }}
);

2. Modify CheckBox selection by clicking

3. Get the selected value in the checkbox

Get multiple marquee
checkbox=$ ("#agentinfo input[name= ' veri[]");
  
  Defines a string concatenation of the resulting values, in order to facilitate the transmission of
  var veri_str = ';
          
  Checkbox.each (function () {
    
    //Decide whether to be selected, here is the reason I want to write this blog, starting with the $ (this). attr (' checked ') ==true judge, but dead
    or Alive/ is to get the value of the previous jquery assignment, the page will get rid of, depressed not, the final fairy help me to fix.
    //To use $ (this). Is (': checked '), do not understand why!
    
    if ($ (this). are (': Checked '))
      
        veri_str+=$ (This). Val () + ', ';//assemble String
  });

The above discussion of jquery set up and get checkbox selected is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud habitat community.

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.