First, the basic understanding: var E = document.getElementById ("Selectid"), E. options= new option ("Text", "value");//Create an Option object, that is, in <select> Label to create one or more <option value= "value" > Text </option>//options is a set of arrays, which can hold multiple <option value= "values" > Text </option > Such tags 1:options[] array properties: The Length property--------The index value of the text in the box that is currently selected, the value of the long attribute---------the Width property of the SelectedIndex property, which is automatically allocated by memory ( 0,1,2,3 ...) corresponds to (first text value, second text value, third text value, fourth text value ...)...) 2: The property of the single option (---obj.options[obj.selecedindex] is a specified <option> tag, is a---) the Text property---------return/Specify The text Value property------return/Specify a value that is consistent with <options value= "..." >. The Index property-------returns the subscript, selected property-------Returns/Specifies whether the object is selected. By specifying TRUE or FALSE, you can dynamically change the selected item Defaultselected property-----Returns whether the object is selected by default. True/false. The 3:option method adds a <option> tag-----obj.options.add (New ("Text", "value");< add > Remove a <option> Tags-----Obj.options.remove (obj.selectedindex) < delete > Get a text-----<option> label Obj.options[obj.selectedindex ].text< > Modify the value of a <option> tag-----obj.options[obj.selectedindex]=new option ("New text", "New value") < change > Delete all <option> Tags-----obj.optIons.length = 0 Gets the value of a <option> tag-----obj.options[obj.selectedindex].value Note: A: The above is written like this type of method Obj.options.function () without writing Obj.funciton, because in order to consider compatibility under IE and FF, such as Obj.add () can only be effective in IE. b:o option in Bj.option does not need to be capitalized, option in new option needs to be capitalized
JavaScript HTML (select option) detailed