<Select id = "Select1" name = "D1">
<Option selected = "selected" value = "1"> 1 </option>
<Option value = "Guangdong"> 2 </option>
<Option value = "3"> 3 </option>
</Select>
1.doc ument. getElementById ("Select1 "). options. length = 0, juery implementation: $ ("# Select1 "). attr ("length", 0); $ ("# Select1 "). empty ();
2. var value = $ ("# Select1"). val (); value
3. $ ("# Select1"). append ("<option value = 'value'> text </option>"); add data
4. $ ("# Select1 option [value = Fujian]"). attr ("selected", "selected"); set or use
$ ("# Select1 option"). each (function (){
If ($ (this). val () = 'fujian '){
$ (This). attr ("selected", true );
}
});
5. $ ("# Select1") [0]. options. add (new Option ('text', 'value'); [0] This format can be returned to the native DOM.
Or $ ("# Select1"). get (0). options. add (new Option ('text', 'value '));
6. var keys = [];
Var values = [];
$ ("# LbHas option"). each (function (){
Keys. push ($ (this). attr ("value "));
Values.push({(this}.html ());
});
For (var I = 0; I <keys. length; I ++ ){
$ ("# LbAll option [value =" + keys [I] + "]"). remove ();
}
7.
If ($ ("# _ SupplyType option [selected = selected]" ).html () = "") // unavailable, the selected attribute is selected in IE8, the selected attribute is not available in IE6 and other browsers.
If (document. getElementById ("_ SupplyType"). options [document. getElementById ("_ SupplyType"). selectedIndex]. text = "") // feasible
If ($ ("# _ SupplyType option: selected" ).html () = "") // feasible
8.
How does jquery exit the each loop?
Return false in the callback function. This applies to most jq methods.
==================================================== 'False' will be returned stop a loop (like using 'Break' in a normal loop ').
Return 'true' to jump to the next loop (just like using 'contine' in a normal loop ').