Home  >  Article  >  Web Front-end  >  javascript对select标签的控制(option选项/select)_javascript技巧

javascript对select标签的控制(option选项/select)_javascript技巧

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

html中的select标签,也是asp.net中的asp:DropDownList控件。
javascript对它们的操作
一、基础理解

复制代码 代码如下:

var e = document.getElementById("selectId");
e. options= new Option("文本","值") ;
//创建一个option对象,即在

1:options[ ]数组的属性:
length属性---------长度属性
selectedIndex属性--------当前被选中的框中的文本的索引值,此索引值是内存自动分配的(0,1,2,3.....)对应(第一个文本值,第二个文本值,第三个文本值,第四个文本值..........)
2:单个option的属性(---obj.options[obj.selecedIndex]是指定的某个
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn