Js gets the selected value of the select tag, js gets the select tag
Var obj = document. getElementByIdx_x ("testSelect"); // locate the id
Var index = obj. selectedIndex; // select an index
Var text = obj. options [index]. text; // select the text
Var value = obj. options [index]. value; // The selected value.
Obtain the selected select value in jQuery.
Method 1
$ ('# TestSelect option: selected'). text (); // The selected text
$ ('# TestSelect option: selected'). val (); // The selected value.
$ ("# TestSelect"). get (0). selectedIndex; // Index
Method 2
$ ("# TesetSelect"). find ("option: selected"). text (); // The selected text
....... Val ();
....... Get (0). selectedIndex;
How does js obtain the select option value?
Document. getElementById ("sect"). value ----- This is to obtain the selected value
Document. getElementById ("sect"). options ------ this is to obtain all the values in the select statement, which is an array
How does JS obtain the option with a value equal to 4 under the SELECT tag and make the option selected ?? Only javascript is supported.
Var str1;
Var myCheckbox1 = document. getElementsByName ("taskCrcletime ");
For (var I = 0; I <myCheckbox1.length; I ++ ){
If (myCheckbox1 [I]. value = 4 ){
Str1 + = myCheckbox1 [I]. value;
Document. getElementsByName ("taskCrcletime"). checked = true;
}
}