JavaScript HTML (select option) detailed

Source: Internet
Author: User

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

Related Article

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.