Home >Web Front-end >JS Tutorial >JavaScript control of select tag (option option/select)_javascript skills

JavaScript control of select tag (option option/select)_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:42:301230browse

The select tag in html is also the asp:DropDownList control in asp.net.
Javascript's operations on them
1. Basic understanding

Copy code The code is as follows:

var e = document.getElementById("selectId");
e. options= new Option("text","value");
//Create an option object, That is, create one or more
//options is an array, which can store multiple Tags like this

1: options[ ] array attributes:
length attribute---------length attribute
selectedIndex Attributes--------The index value of the text in the currently selected box. This index value is automatically allocated by the memory (0,1,2,3...) corresponding to (the first text value , the second text value, the third text value, the fourth text value...)
2: Attributes of a single option (---obj.options[obj.selecedIndex] It is a specified