Form form check box checkbox action

Source: Internet
Author: User

Input check (checkbox): <label>input Check 1 group: </label><input type= "checkbox" Name= "CheckBox1" value= " CheckBox Check 1 "checked=" checked "/>checkbox check 1<input type=" checkbox "Name=" CheckBox1 "value=" checkbox check 2 "/> CheckBox Check 2<input type= "checkbox" Name= "CheckBox1" value= "checkbox check 3" checked= "Checked"/> CheckBox Check 3 single option of same name for the same set of check, checked= "checked" to select a complex option; 1.checkbox selected item's value and index (actually should be called ordinal, the value of index () starts from 1, not 0) <label> Input Check 2 group: </label><input type= "checkbox" Name= "CheckBox2" value= "checkbox Check 1"/>checkbox check 1<input type= "checkbox" Name= "CheckBox2" value= "checkbox check 2" checked= "checked"/>checkbox check 2<input type= "checkbox" Name= "CheckBox2" value= "checkbox check 3" checked= "checked"/>checkbox check 3$ ("Input[name= ' CheckBox2 ']:checked"). Val () ;//The first value of the selected item is $ ("Input[name= ' CheckBox2 ']:checked"). each (function () {  alert ("Value of the CheckBox2 group check:" +$ (This). Val ()) ;//traverse the value of the selected item}); var index1 = $ ("input[name= ' CheckBox2 ']:checked"). index ();//The first ordinal of the selected item alert ("CheckBox2 Group checked item:" +index1 ); $ ("Input[name="CheckBox2 ']:checked '). each (function () {//) iterates through the sequence number of the selected item   alert ("Item of the CHECKBOX2 group checked item:" +$ (This). index ()); The value corresponding to the index and index of the 2.checkbox value <label>input check 3 groups: </label><input type= "checkbox" Name= "Checkbox3" value= " CheckBox Check 1 "/>checkbox check 1<input type=" checkbox "Name=" Checkbox3 "value=" checkbox check 2 "/>checkbox check 2< Input type= "checkbox" Name= "Checkbox3" value= "checkbox check 3"/>checkbox check 3checkbox index corresponding value: $ ("input[name=" Checkbox3 "]"). EQ (2). Val ();//checkbox check 3;eq (index value), index starting at 0, index for checkbox value: $ ("input[name= ' Checkbox3 '][value=checkbox check 2]"). Index ();//2;index (ordinal), sequence number starting from 1 $ ("Input[name= ' Checkbox3 ']:first"). Val ();//checkbox the value of the first item $ ("Input[name= ' Checkbox3 ') : First "). index ();//checkbox (" Input[name= ' Checkbox3 ']:last "). Val ();//checkbox the value of the last item $ (" Input[name= " Checkbox3 ']:last '). index ();//checkbox the last item, 3.checkbox checked and unchecked: <label>input Check 4 Group: </label><input type= "checkbox" Name= "checkbox4" value= "checkbox Check 1"/>checkbox check 1<input type= "checkbox" Name= "Checkbox4" Value= "CheckboX Check 2 "/>checkbox check 2<input type=" checkbox "Name=" checkbox4 "value=" checkbox check 3 "/>checkbox check 3$ (" Input[name= ' Checkbox4 '][value= ' checkbox check 1 '] "). Prop (" checked ", true);//Select a value corresponding to the item $ (" Input[name= ' checkbox4 '][value= ' CheckBox Check 1 '] "). Prop (" checked ", false);//uncheck a value corresponding to the item $ (" Input[name= ' checkbox4 '][value= ' checkbox check 2 '] "). Prop (" Checked "," checked ");//Select a value corresponding to the item $ (" Input[name= ' checkbox4 '][value= ' checkbox check 2 '] "). Removeprop (" checked ");// Uncheck the item that corresponds to a value of $ ("Input[name= ' checkbox4"). EQ (1). Prop ("checked", true);//select an index corresponding to the item $ ("Input[name= ' checkbox4 ']"). EQ (1 ). Prop ("checked", false);//uncheck the item corresponding to the index ("Input[name= ' checkbox4 ')"). EQ (2). Prop ("Checked", "checked");//select the item corresponding to an index $ ("Input[name= ' checkbox4 ')". EQ (2). Removeprop ("checked");//Uncheck the entry for an index 4.checkbox delete item: <label>input Check 5 groups:< /label><input type= "checkbox" Name= "checkbox5" value= "checkbox Check 1"/>checkbox check 1<input type= "checkbox" Name= "checkbox5" value= "checkbox check 2"/>checkbox check 2<input type= "checkbox" Name= "checkbox5" value= "checkbox check 3" />checkbox Check 3$ ("Input[name= ' checkbox5 ')". EQ (1). Remove (), or $ ("Input[name= ' checkbox5 '][value=checkbox check 2]"). Remove (); Remove the checked item; Reference from: http://www.jb51.net/article/77946.htmhtml content: <! DOCTYPE html>Input{margin-top:0.3em;margin-bottom:0.3em;}. Tipmsg{font-size:14px;color: #f00;} </style><input type= "checkbox" Name= "CheckBox1" value= "checkbox check 2"/>checkbox Check 2<input type= "checkbox" Name= "CheckBox1" value= "checkbox check 3" checked= "Checked"/>checkbox Check 3<span class= "Tipmsg" >A single option of the same name is the same set of checkboxes, checked= "checked" selects a complex option;</span> </div> <input type= "checkbox" Name= "CheckBox2" value= "checkbox check 2" checked= "Checked"/>checkbox Check 2<input type= "checkbox" Name= "CheckBox2" value= "checkbox check 3" checked= "Checked"/>checkbox Check 3<span class= "Tipmsg" ><br>$ ("Input[name= ' CheckBox2 ']:checked"). Val ();//returns only the first value of a selected item <br>Each traversal gets the value of multiple checked items;<br>$ ("Input[name= ' CheckBox2 ']:checked"). Val ();//returns only the first ordinal of a selected item <br>Each traversal gets the ordinal of multiple checked items;<br></span> </div> <input type= "checkbox" Name= "Checkbox3" value= "checkbox check 2"/>checkbox Check 2<input type= "checkbox" Name= "Checkbox3" value= "checkbox check 3"/>checkbox Check 3<span class= "Tipmsg" ><br>$ ("Input[name= ' Checkbox3 ')"). EQ (2). Val ();//checkbox check 3;eq (index value), index starting from 0 <br>$ ("Input[name= ' Checkbox3 '][value=checkbox check 2]"). index ();//2;index (serial number), starting from 1 <br>$ ("Input[name= ' Checkbox3 ']:first"). Val ();//checkbox the value of the first item <br>$ ("Input[name= ' Checkbox3 ']:first"). index ();//checkbox indexes of the first item <br>$ ("Input[name= ' Checkbox3 ']:last"). Val ();//checkbox the value of the last item <br>$ ("Input[name= ' Checkbox3 ']:last"). index ();//checkbox of the last item</span> </div> <input type= "checkbox" Name= "checkbox4" value= "checkbox check 2"/>checkbox Check 2<input type= "checkbox" Name= "checkbox4" value= "checkbox check 3"/>checkbox Check 3<span class= "Tipmsg" ><br>$ ("Input[name= ' checkbox4 '][value= ' checkbox check 1 ']"). Prop ("checked", true);//Select a value corresponding to the item <br>$ ("Input[name= ' checkbox4 '][value= ' checkbox check 1 ']"). Prop ("checked", false);//uncheck the item corresponding to a value <br>$ ("Input[name= ' checkbox4 '][value= ' checkbox check 2 ']"). Prop ("Checked", "checked");//Select a value corresponding to the item <br>$ ("Input[name= ' checkbox4 '][value= ' checkbox check 2 ']"). Removeprop ("checked");//uncheck the item corresponding to a value <br>$ ("Input[name= ' checkbox4 ')"). EQ (1). Prop ("checked", true);//Select the item that corresponds to an index <br>$ ("Input[name= ' checkbox4 ')"). EQ (1). Prop ("checked", false);//uncheck the item corresponding to an index <br>$ ("Input[name= ' checkbox4 ')"). EQ (2). Prop ("Checked", "checked");//Select the item that corresponds to an index <br>$ ("Input[name= ' checkbox4 ')"). EQ (2). Removeprop ("checked");//uncheck the item corresponding to an index</span> </div> <input type= "checkbox" Name= "checkbox5" value= "checkbox check 2"/>checkbox Check 2<input type= "checkbox" Name= "checkbox5" value= "checkbox check 3"/>checkbox Check 3<span class= "Tipmsg" ><br></span> </div></form> <script src= "./jquery-1.x.min.js" ></script><script>$ ( function () {var val1 = $ ("input[name= ' CheckBox2 ']:checked"). Val ();//Gets the value of a single complex option, and returns only the lowest value for all selected items if multiple selections are selected;//alert (VAL1)    ; $ ("Input[name= ' CheckBox2 ']:checked"). each (function () {Alert (the value of the CheckBox2 group checked item: +$ (This). Val ());//traverse the value of the selected item});  var index1 = $ ("input[name= ' CheckBox2 ']:checked"). index ();  Alert ("CheckBox2 item for the selected item:" +INDEX1); $ ("Input[name= ' CheckBox2 ']:checked"). each (function () {Alert ("CheckBox2 item for the selected item:" +$ (This). index ());//Traversal of the selected item's indexes  });    var val2 = $ ("input[name=" Checkbox3 ']). EQ (2). Val (); //alert ("Checkbox3 index 2 corresponds to:" +val2);//checkbox Check 3 (EQ (index value) index value starting from 0)   Var Index2 = $ ("input[name= ' Checkbox3 '][value=checkbox check 2]"). Index (); //alert ("Checkbox3 value checkbox Check 2" corresponds to: "+ INDEX2);    var var3 = $ ("input[name= ' Checkbox3 ']:first"). Val ();//checkbox the value of the first item  //alert (VAR3);   var index3 = $ ("input[name= ' Checkbox3 ']:first"). index ();//checkbox indexes of the first item  //alert (VAR3); //alert ( INDEX3);    var VAR4 = $ ("input[name= ' Checkbox3 ']:last"). Val ();//checkbox the value of the last item  //alert (VAR4);   var index4 = $ ("input[name= ' Checkbox3 ']:last"). index ();//checkbox of the last item  //alert (INDEX4);    //$ ("Input[name= ' checkbox4 '][value= ' checkbox check 1 ']"). Prop ("checked", true);//Select a value corresponding to the item  //$ ("Input[name = ' checkbox4 '][value= ' checkbox check 1 '] "). Prop (" checked ", false);//uncheck a value corresponding to the item  //$ (" Input[name= "CheckboX4 '][value= ' checkbox check 2 '] "). Prop (" Checked "," checked ");//Select a value corresponding to the item  //$ (" Input[name= ' checkbox4 '][value= ') CheckBox Check 2 '] "). Removeprop (" checked ");//uncheck a value corresponding to the item     $ (" Input[name= ' checkbox4 '] "). EQ (1). Prop (" Checked ", true);//select an index corresponding to the item   $ (" Input[name= ' checkbox4 ') "). EQ (1). Prop (" checked ", false);//uncheck the item corresponding to an index   $ ( "Input[name= ' checkbox4 ')". EQ (2). Prop ("Checked", "checked");//select an index corresponding to the item   $ ("Input[name= ' checkbox4 ']"). EQ (2) . Removeprop ("checked");//uncheck the corresponding entry for an index    //$ ("Input[name= ' checkbox5 ']"). EQ (1). Remove ();  $ (" Input[name= ' checkbox5 '][value=checkbox check 2] "). Remove ();}); </script></body>

check box of form form checkbox action

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.