html中select在js中的操作(再总结一下)

//添加
var Select1= document.getElementById("Select1");
1.Select1.options[0]=new Option('a','0');

2.Select1.options.add(new Option('a','0'));
其中1的options[0],0是索引,所以好一点
//获取当前的value值
var www=Select1.value;
//获取当前的text值
var w=Select1.options[Select1.selectedIndex].text;
//动态删除select中的所有options
Select1.options.length=0;
//动态删除select中的某一项option:
Select1.options.remove(indx); 
//获取value
Select1.options[Select1.selectedIndex].value
//获取value
Select1.options[Select1.selectedIndex].text
原文地址:https://www.cnblogs.com/cuihongyu3503319/p/833155.html