function btnAdd_onclick()"{ var opt=new Option('New York','1'); document.fm.citys.options[0]=opt;}<form id="fm" name="fm">... <select name="citys" id="citys">
删除select中的某一项option:
document.getElementById("citys").options.remove(indx);
删除select中的所有options:
document.getElementById("citys").options.length=0;
添加select中的项option:
document.getElementById("citys").options.add(new Option(text,value));
取值:
function getvalue() { var obj = document.getElementById('citys'); var m=obj.options[obj.selectedIndex].value alert(m);//获取value var n=obj.options[obj.selectedIndex].text alert(n);//获取文本 }
相关资源:javascript 获取select ->option中id、value、label属性及<option></option>中内容