Checkbox,select,radio and so on can be used to assign values
Note: Both 1.checkbox and radio must be assigned a value in an array; 2. Cannot assign a value to it by ID, eg:$ ("#ckb") is not able to assign all the checkboxes, so it can only be used $ ("input"), the value of the attribute is added; 3. Creation and understanding of arrays
1. Set the different controls:
1 <SelectID= "single">2 <option>Single</option>3 <option>Single2</option>4 </Select>5 <SelectID= "multiple"multiple= "multiple">6 <option>Multiple</option>7 <option>Multiple2</option>8 <option>Multiple3</option>9 </Select><BR/>Ten <inputtype= "checkbox"value= "Check1"ID= "CKB"/>Check1 One <inputtype= "checkbox"value= "Check2"ID= "CKB"/>Check2 A <inputtype= "checkbox"value= "Check3"ID= "CKB"/>Check3 - <inputtype= "checkbox"value= "Check4"ID= "CKB"/>Check4 - <inputtype= "Radio"value= "Radio1"ID= "Rad"/>Radio1 the <inputtype= "Radio"value= "Radio2"ID= "Rad"/>Radio2
2.jquery Code
1 <Scripttype= "Text/javascript">2 $(function(){3 $("#single"). Val ("Single2");4 $("#multiple"). val (["Multiple2", "Multiple3"]);5 varT= "Check1;check2";6 varh=T.split (";");7 $("Input[type=checkbox]"). Val (h); 8 vars="Radio2";9 varrad=[s];Ten Alert (RadinstanceofArray); One $("input"). Val (RAD); A }) - </Script>
How to use jquery to assign values to a checkbox