ITeye博客

option操作小结

cindysaj · 2008-12-01 17:30 · select/option · Markdown

1在select列表第一行增加一个option的方法 方法1.document.getElementById("sel").add(new Option("1","1"),0);

方法2var y=document.createElement('option'); y.text='2'; y.value='2'; document.getElementById("sel").add(y,0); //0为索引号

2在select列表第一行修改一个option的方法,注意是覆盖 document.getElementById('selectId').options[0] = new Option("1","1");

3在select列表删除一个option的方法 document.getElementById("sel").remove(0);//0为索引号

评论(0)

暂无评论。

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