ITeye博客

js操作select

xchyou · 2012-09-13 10:05 · javascript · Web前端 · js select option · Markdown

//已经选中的(accList是select的id)

var id = document.all.accList.selectedIndex;

var values = document.all.accList.options[id].value;

var accid = document.all.accList.options[id].text;

 

//动态新增(删除)option

var selects = document.getElementsByTagName('select');

 

var optionNode = new Option(eo.packageid,eo.packageid);

selects[0].add(optionNode);

 

var options = selects[0].options.length;

 

for(var i = options-1;i >= 1;i--)

{  

selects[0].options.remove(i);

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。