🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
```html <select id="mySelect"> <option>Apple</option> <option>Orange</option> <option>Pineapple</option> <option>Banana</option> </select> ``` ```javascript var Select = document.getElementById("mySelect"); //select option长度 var selectedLength = Select.options.length; //select当前选中哪个 var selectedIndex = Select.options.selectedIndex; //获取option的text、value、index var optionValue = Select.options[selectedIndex ].text; var optionValue = Select.options[selectedIndex ].value; var optionIndex = Select.options[selectedIndex ].index; //添加option项 Select.options[index]=new Option("text","value");//for.i 循环 Select.options.add(new Option("text","value")); //删除option项 Select.options.remove(index); ```